Reputation: 23495
I'm trying to add and update a simple data, what is wrong with my request ?
I'm using the website https://www.jdoodle.com/online-mongodb-terminal
#1
db.Vendor.find()
#2
db.Vendor.insert({
employee: [
ObjectId('fffffa000000000000000002'),
ObjectId('fffffa000000000000000003')
]
});
#3
db.Vendor.update({
"employee": ObjectId("fffffa000000000000000002")
}, {
$push: {
"employee" : ObjectId("fffffa000000000000000004")
}
});
Upvotes: 1
Views: 707
Reputation: 37028
It's jdoodle terminal specific I guess. The document should be a valid json, not just a js object as in the cli mongo shell.
db.Vendor.update({
"employee": ObjectId("fffffa000000000000000002")
}, {
"$push": {
"employee" : ObjectId("fffffa000000000000000004")
}
});
does the job.
Upvotes: 2