Is there a way to make a query that:
In the end we will receive all documents where certain field have matched condition AND all document where such field doesn't exist at all.
How about something like this:
db.stackoverflow.find({
$or: [
{ howmuch: { $exists:false } },
{ howmuch:5 }
]})
In the stackoverflow collection, this will find all documents that do not have the howmuch
field plus all documents that do have howmuch
set to 5.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With