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

python - jinja2: TemplateSyntaxError: expected token ',', got 'string' -

Qt4: how to send QString inside a struct via QSharedMemory -

node.js - NodeJS remote terminal to Dropbear OpenWRT-Server -