node.js - NodeJs Convert string to BSON object -
how can convert string (_id) bson object?
as driver i'm using monk.
monk defines id
, oid
(alias) methods casting objectid
:
users.id() // returns new generated objectid users.id('hexstring') // returns objectid users.id(obj) // returns objectid
though seems capable of working string well:
users.findbyid('hex representation', function(err, doc){}); users.findbyid(oid, function(err, doc){});
Comments
Post a Comment