0

My JSON is:

db.col.insert([

    {
        "1":[
            {
                "a":"1",
                "b":"2",
                "v":"12"
            }
        ]
    },
    {
        "2":[
            {
                "a":"12",
                "v":"451"
            }
        ]
    }])

when I query using

db.col.find("1")

It is returning both the rows instead of the condition. how can i select just one row here?

1 Answer 1

1

You can filter the data by checking if the given field exists using $exists keyword as follows :

db.col.find({1 : {$exists:true}})
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.