I am using MongoDB native driver for NodeJS, and am having trouble converting ObjectID to a string.
My code looks like:
db.collection('user', function(err, collection) {
collection.insert(data, {safe:true}, function(err, result) {
var myid = result._id.toString();
console.log(myid);
)};
});
I have tried various suggestions on StackOverflow like:
myid = result._id.toString();
myid = result._id.toHexString();
but none of them seemed to work.
I am trying to convert the ObjectID to base64 encoding.
Not sure if I am running into supported functionality under the Mongo native driver.