mongoose的findByIdAndUpdate方法不是返回更新后的最新数据吗?为什么我取出来的是旧的数据,事实上数据库中数据是更新了的
A.findByIdAndUpdate(id, update, options, callback) // executes A.findByIdAndUpdate(id, update, options) // returns Query A.findByIdAndUpdate(id, update, callback) // executes A.findByIdAndUpdate(id, update) // returns Query A.findByIdAndUpdate() // returns Query
http://mongoosejs.com/docs/api.html#model_Model.findByIdAndUpdate
@gjc9620 OK,thx
有一个属性 new,可以控制返回的数据,默认的是 false 返回旧数据 new: bool - true to return the modified document rather than the original. defaults to false
CNode 社区为国内最专业的 Node.js 开源技术社区,致力于 Node.js 的技术研究。
http://mongoosejs.com/docs/api.html#model_Model.findByIdAndUpdate
@gjc9620 OK,thx
有一个属性 new,可以控制返回的数据,默认的是 false 返回旧数据 new: bool - true to return the modified document rather than the original. defaults to false