For example, I have collection with documents, where documents can have field "url" (but most of them doesn't). How can I find all documents, which have field "url" (regardless of value of this field)?
To find if a key/field exists in your document use the $exists operator.
Via the MongoDB shell ...
> db.things.find( { url : { $exists : true } } );
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