【发布时间】:2015-07-30 10:10:32
【问题描述】:
我想在 MongoDB 中获取新插入文档的“_id”。找到这个解决方案Get the _id of inserted document in Mongo database in NodeJS 我在 mongo shell 中尝试了这个简单的代码:
var order = { number: 2, completed: false };
db.orders.insert(order, function(err,docsInserted){
console.log(docsInserted);
});
但我得到了下一个:
WriteResult({ "nInserted" : 1 })
这里有什么问题?
【问题讨论】: