I have the following code:
db.users.save({ username: "admin", array: [{ foo1: "foo1", foo2: "foo2" }, { bar1: "bar1", bar2: "bar2" }, { cell1: "cell1", cell2: "cell2" } ] }); Now I want to update the array. I mean to push something into the array:
db.users.update({ username: admin }, { $set: { array: { push1: "push1", push2: "push2" } }, function (err, updated) { The update function doesn't push. So how can I push to the array, so the result will be:
[ { foo1:"foo1", foo2:"foo2" }, { bar1:"bar1", bar2:"bar2" }, { cell1:"cell1", cell2:"cell2" }, { push1:"push1", push2:"push2" } ]