Is there a way to specify a condition of "where document doesn't contain field" ?
For example, I want to only find the first of these 2 because it doesn't have the "price" field.
{"fruit":"apple", "color":"red"}
{"fruit":"banana", "color":"yellow", "price":"2.00"}
db.mycollection.find({ "price" : null })
Try the $exists
operator:
db.mycollection.find({ "price" : { "$exists" : false } })
and see its documentation.
Success story sharing