我有以下代码:
db.users.save({
username: "admin",
array: [{
foo1: "foo1",
foo2: "foo2"
}, {
bar1: "bar1",
bar2: "bar2"
}, {
cell1: "cell1",
cell2: "cell2"
}
]
});
现在我想更新数组。我的意思是将一些东西推入数组:
db.users.update({
username: admin
}, {
$set: {
array: {
push1: "push1",
push2: "push2"
}
},
function (err, updated) {
更新功能不推送。那么我怎样才能推送到数组,所以结果将是:
[
{ foo1:"foo1", foo2:"foo2" },
{ bar1:"bar1", bar2:"bar2" },
{ cell1:"cell1", cell2:"cell2" },
{ push1:"push1", push2:"push2" }
]