javascript - Finding MongoDB Document by ID -


i'm using node.js , mongodb database hosted on mongohq (now compose.io). have general understanding document ids converted hex strings can't figure out how retrieve document using id.

my document has id _id: objectid("53f13064b5a39cc69f00011b") in that's how it's displayed in compose's interface. when retrieve document brute force, id shown _id: 53f13064b5a39cc69f00011b.

what use in node.js retrieve document? query:

systemdata.find({_id: "53f13064b5a39cc69f00011b"}).toarray(function(err, data) {//do stuff} 

returns empty set querying object id object

systemdata.find({_id: new objectid("53f13064b5a39cc69f00011b")}).toarray(function(err, data) {//do stuff} 

what missing?

you should able use:

systemdata.find({_id: objectid("53f13064b5a39cc69f00011b")}) 

no need "new" on beginning.


Comments

Popular posts from this blog

java - How to specify maven bin in eclipse maven plugin? -

single sign on - Logging into Plone site with credentials passed through HTTP -

php - Why does AJAX not process login form? -