好吧.. 这很奇怪而且很烦人,所以我们将不胜感激任何帮助。这是我的代码:
Target.update {location_city: "New York"}, {location_country: "FUDGE!"}, {safe: true}, (err, res) ->
console.log "Updating with New York"
console.log res
console.log "Err #{err}"
没有错误,NADA。但出于某种原因,只有第一个文档得到更新。当我对 SAME 查询运行查找时,我得到了多个结果。
如有任何帮助,我们将不胜感激。
最佳答案
multi
必须是 true
。
所以正确的查询应该是
Target.update {location_city: "New York"}, {location_country: "FUDGE!"}, {multi: true}, (err, res) ->
console.log "Updating with New York"
console.log res
console.log "Err #{err}"
关于node.js - Mongoose 更新只更新第一个文件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7756534/