I would like to execute a following query:
db.mycollection.find(HAS IMAGE URL)
What should be the correct syntax?
databasemongodbnosql
I would like to execute a following query:
db.mycollection.find(HAS IMAGE URL)
What should be the correct syntax?
Best Answer
This will return all documents with a key called "IMAGE URL", but they may still have a null value.
This will return all documents with both a key called "IMAGE URL" and a non-null value.
Also, according to the docs, $exists currently can't use an index, but $ne can.
Edit: Adding some examples due to interest in this answer
Given these inserts:
This will return all three documents:
This will return the first and second documents only:
This will return the first document only:
This will return the second and third documents only: