I would like to get find a key which is not there in MongoDB document. Please find the following document.
{
"_id" : ObjectId("523b6e61fb408eea0eec2648"),
"userid" : "abby",
"score" : 82
}
I have a requirement that I need to query Mongo DB with a key which is not there in any document . say key =name. my db collection size is 10 GB. Now, I want to check the collection that the key = name is there or not ?
db.getCollection('score').find({"name":{$exists:true}})
the above query is taking more than 10 sec to find that weather the key name is there in the document or not. my question is that is there any way to get the response immediately if the specified key is not here in that document.
my question is different because when I check the link provided , I came to know that they are checking the existing key in a document. but in my case checking a key which is not there in any document.