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.
Hi, .remove() will actually remov the whole document, not part of document. What you might want to do is to update a document to set/unset a key in it.
Try - .updateOne({//matching conditions}, {$unset:{"items.item_16414806548": ""}})
This will unset (update the document to remove that key) the key, and when you write it in dot notation, it can access the internal key item_16414806548 from items.
Checkout - $unset
Thank you! Going to give that a try! Is there a way I can pass the items.item_16414806548 in as a variable. I cannot seem to put a variable in there to save my life. Thanks again for responding!