Sriman
Sriman

Reputation: 788

Mongo Query on a JSON object

I have an element in a mongoDB collection that looks like below. The value "abcdefgh" changes for each row. How do I query to get the row that has the value "abcdefgh" within the object that is stored under the _id field?

"_id": {
    "abcdefgh": {
        "w": true,
        "r": true
    }

Upvotes: 4

Views: 3621

Answers (1)

DAXaholic
DAXaholic

Reputation: 35328

Have a look at the $exists operator, i.e. try something like this

db.yourCollection.find({"_id.abcdefgh": { "$exists": true } })

Upvotes: 4

Related Questions