7

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. BUT only the FIRST document gets updated for some reason. When I run a find on the SAME query, I get multiple results.

Any help would be AWESOMELY appreciated.

Shamoon
  • 41,293
  • 91
  • 306
  • 570

1 Answers1

14

multi has to be 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}"
Shamoon
  • 41,293
  • 91
  • 306
  • 570
  • Thank you so much! I couldn't find this in Mongoose's documentation though I find it hard to believe that they would leave out such an important switch. – Ege Özcan Nov 09 '12 at 08:02