'Can not find a record by it's _id in mongoDB

I want to get a record by its _id like this:

db.user.find({_id : ObjectId("53a095aa4568cb1fef93f681")})

As you can see the record exists:

mongoDB record by _id

I think my way is correct according to:

So what's wrong with my code? I'm using RoboMongo.



Solution 1:[1]

If you are using python, Try this,

from bson import ObjectId
db.user.find({_id : ObjectId("53a095aa4568cb1fef93f681")})

Solution 2:[2]

Sometime it is right to find _id as a str, sometime it is right to find _id as an ObjectId, it depends on where you are.

a. NoSQLBooster/Pymongo:

db.user.find({_id : ObjectId("53a095aa4568cb1fef93f681")})

b. Robo3T/RoboStudio

db.user.find({_id : "53a095aa4568cb1fef93f681"})

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Shirantha Madusanka
Solution 2 K. Symbol