mongoose中如何取得findAndModify的返回值?
发布于 13 年前 作者 namiheike 12433 次预览 最后一次回复是 13 年前 来自
SomeSchema.statics.findAndModify = function (query, sort, doc, options, callback) {
return this.collection.findAndModify(query, sort, doc, options, callback);
};
mongoose.model('Some',SomeSchema);
然后findAndModify
Some.findAndModify({}, [], { $inc: { amount: 1 } }, {'new':true}, function (err) {
if (err) throw err;
});
似乎成功的给amount加了1,但是我想直接取得新amount的值,有办法么?
1 回复
http://stackoverflow.com/questions/9773684/how-to-get-the-return-value-of-findandmodify-func-in-mongodb-with-mongoose