this._MyModel.findOneAndUpdate(
{ email },
{
$set: {
'tradeAccount': {
limitType,
limit,
}
},
$push: {
'tradeAccount.history': history
}
}
);
I want to add another object into an existing array using $push but in the same time I am performing another update on the same object using $set.
I know that I cannot use two operators on the same field such as ($set and $push).
I wonder if there is another way to add another object into an existing array using $set, or if there is any other way to do this in the same update request.
I was thinking of updating the array using $set by retrieving the existing history and concatenate with the new one. But that requires an extra call to the db.