0
{  
 "_id": {    
    "$oid": "1234567"  
 },  
 "para": {       
   "lisobj": {      
       "abcd": 
        [  "1234"      ]    
   },
 }
}

I have the above mongo doc, I am trying to write a filter to see if there are any doc which have the following key:

"para.lisobj.abcd" exists.

But I am not sure what would be the proper mongo filter to find the doc which has the field.

I tried the below filter but it doesn't work:

{"para.lisobj.abcd" : { "exists": true} }

1 Answer 1

1

You miss $ at exists

db.collection.find({
  "para.lisobj.abcd": {
    $exists: true
  }
})

mongoplayground

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.