Mongodb & Meteor - Query To Push Into Nested Array Does Not Work, No Error Thrown
I am attempting to push data into a nested array inside of a Mongo collection. I've followed along the Mongo documentation here, http://docs.mongodb.org/manual/reference/operator/u
Solution 1:
Remove the positional operator($
) from the query
parameter of the update
function.
Meteor.users.update(
{
_id:options.userId,
'buyer.boards.title':options.boardTitle
},
{ $push: {
'buyer.boards.$.idArr':options.newId }
}
);
From the docs:
db.collection.update(
{ <array>: value ... },
{ <updateoperator>: { "<array>.$" : value } }
)
The positional operator should be used in the update
parameter and not in the query
parameter. This updates only the first boards
object that has the matching title
.
Post a Comment for "Mongodb & Meteor - Query To Push Into Nested Array Does Not Work, No Error Thrown"