0

I have a collection in mongoDB,

MyCol =
{
"_id" : ObjectId("5e0d6fb6dd92a8b5cf8d8cf4"),
"GUID" : "1",
"'340161'" : 0.951692342758179,
"'278005'" : 0.947725296020508,
"'277983'" : 0.947490692138672
}

{
"_id" : ObjectId("5e0d6909dd92a8b5cf8d7db8"),
"GUID" : "2",
"'328233'" : 0.906306743621826,
"'1780743238714207XzexMx'" : 0.906214714050293,
"'1521747748662913YHHH1q'" : 0.903554856777191,
"'1550050896309755Aj1WgM'" : 0.902812838554382,
"'328344'" : 0.902668118476868,
"'328969'" : 0.90227073431015,
} 

If I want to fetch GUID : 1 , I use db.getCollection('Name').find({GUID : "1"}). But I want to fetch the document where GUID:"1" and the key '340161' in that document. How I can use exist function to it?

Is there something like,

db.getCollection('Name').find({GUID:"1",'340161' : { $exists: true }})
Ashh
  • 44,693
  • 14
  • 105
  • 132
Jennifer Therese
  • 1,105
  • 9
  • 17

0 Answers0