I am developing API using loopback + mongoDB. In that i have to update an array in a document in mongoDB:
My model:
{
"userId": "546fgdfgd445",
"rrrr": "7",
"bbbbb": [
{}
],
"id": "57a437789521b58b12124016"
}
I need to update the array with new element with the data sent form client:
app.models.vvvvv.update({ userId: '546fgdfgd445' },{ $push: { "transactions": transactionData }}, function(err, res){
if(err){
console.log(err);
} else {
console.log(res);
}
});
But i am receiving error:
{ name: 'MongoError',
message: 'The dollar ($) prefixed field \'$push\' in \'$push\' is not valid for storage.',
driver: true,
index: 0,
code: 52,
errmsg: 'The dollar ($) prefixed field \'$push\' in \'$push\' is not valid for storage.' }
I am using mongoDb version 3.2.3.
Please share your ideas. Thanks in advance.
transactionData?Seems there is something wrong with that.