I’ve got a document that looks like this:
{listName: 'LoremIpsum'
listItems: [{productDescription: "", productImage: ""}...]}
How would I go about deleting an item from listItems if productImage didn’t exist?
I’ve tried the following with no result:
db.lists.update({"item.productImage":{$exists: false}}, {$unset:{"item":1}}, false, true )
Note that $pull can contain element matching criteria. As such this single update will remove the items that do not contain the field “productImage” :