[英]Mongoose update only updates first document
Okay.. this is odd and annoying, so any help would be GREATLY appreciated. 好的..这很奇怪而烦人,所以任何帮助都会非常感激。 Here's my code:
这是我的代码:
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}"
No error, NADA. 没错,NADA。 BUT only the FIRST document gets updated for some reason.
但是只有FIRST文档因某种原因而更新。 When I run a find on the SAME query, I get multiple results.
当我在SAME查询上运行查找时,我得到多个结果。
Any help would be AWESOMELY appreciated. 任何帮助都会非常感激。
multi
has to be true
. multi
必须是true
。
So the correct query would be 所以正确的查询将是
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}"
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.