0

Here is a record from my mongoDB. I am trying to query it and using Pymongo.

{
        "_id" : ObjectId("5925665bcb98a11aa4ca23f8"),
        "EMAIL" : "jaffer@example.com",

        "LOGIN" : [
                "example"
        ],
        "NAME" : [
                "example name"
        ],
        "URL" : [
                "http://example.com"
        ]
}

I am trying to access the documents where the Key NAME is available.
I tried to query something like this:

db.ff.find({"NAME":[]})
db.ff.find({"NAME":[1]})

I do not get any output.
When I made the specific query the result appeared.

db.ff.find({"NAME":["example name"]})

But I do not know how many records has NAME as array key. Kindly, let me know how to find the record that have the Array Key as NAME.

KARTHIKEYAN.A
  • 18,210
  • 6
  • 124
  • 133
Jaffer Wilson
  • 7,029
  • 10
  • 62
  • 139

1 Answers1

1

you use $exists and $ne to find the value

db.ff.find({ "NAME": { $exists: true, $ne: null } })
KARTHIKEYAN.A
  • 18,210
  • 6
  • 124
  • 133