Hello, I am a new to MongoDB and I seeking help.
I have a document in my collection that looks like this:
_id:5f2f40b8d1287d5c98309cb9
foo: "Some value"
zed: "Another Thing"
items: Object
item_16414803554: Object
name: "Some Name"
age: "45"
item_16414806548: Object
name: "Some Name"
age: "45"
I am using mongojs to work with the data and I need to remove one of the sub objects like “item_16414806548”. I cannot figure out what the query should be to do so.
I tried this:
db.mycollection.remove({_id: mongojs.ObjectId(id)}, {items: {_id: {$eq: itemid }}}, function(err, doc) {
res.json(doc);
});
But that’s not working. Can anyone tell me what the proper query would be? Thanks for any help!