node.js - MongoDB insert operation returns WriteResult instead of inserted doc -


i want '_id' of newly inserted document in mongodb. finding solution get _id of inserted document in mongo database in nodejs tried simple code in mongo shell:

var order = { number: 2, completed: false }; db.orders.insert(order, function(err,docsinserted){     console.log(docsinserted); }); 

but next:

writeresult({ "ninserted" : 1 }) 

what wrong here?

the answer/method trying utilise referring api mongodb driver node.js. equivalent expression in mongo shell return write result (the callback won't work in shell).

to review inserted document in shell, still need make use of find suggested here in docs.


Comments

Popular posts from this blog

qt - Using float or double for own QML classes -

Create Outlook appointment via C# .Net -

ios - Swift Array Resetting Itself -