Update all field values that match a criteria

mongodb

Solution

From the Mongo docs-

By default, the update() method updates a single document that matches its selection criteria. Call the method with the multi option set to true to update multiple documents.

So you should run your query like this:

db.posts.update(
  {author:{$lt:0}},
  {$set:{author:582127753}},
  { multi: true }
)

Problem

I'm trying to change the value of author where the value is lower than 0 I use this but no result : ``` db.posts.update({author:{$lt:0}},{$set:{author:582127753}}) ``` any Ideas ?

Original source