Mongoose update only updates the first document

Well .. it's weird and annoying, so any help would be greatly appreciated. Here is 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}" 

Error, NADA. But for some reason, only the FIRST document is updated. When I run a search in the EXACT query, I get several results.

Any help would be FREE appreciated.

+6
source share
1 answer

multi must be true .

So the correct request will 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}" 
+13
source

Source: https://habr.com/ru/post/899236/


All Articles