Db.getcollection ('Product').Update({Status: "Offline"},{$Set: {status: "Online"}},false,true) update, change all status offline to online, note quotes db.collection.Update(criteria, objnew, Upsert, Multi) The description of the four parameters is as follows: The criteria:update query condition, similar to the one in the SQL update query where the following objnew: Update the object and some updated operators (such as $, $inc ... ), and so on, can also be understood as Upsert after the set in SQL Update query: This parameter means that if there is no record of update, insert Objnew,true is inserted, default is False, not inserted. Multi:mongodb default is False, only update the first record found, if this parameter is true, the condition is checked out all the records are updated. Several query examples are as follows: Db.mytest.Update({Count: {$gt:1}},{$Set: {name: "OK"}}) Update only the first record db.mytest.Update({Count: {$gt:3}},{$Set: {name: "OK"}},false,true) more than 3 of all updated db.mytest.Update({Count: {$gt:4}},{$Set: {name: "ok123"}},true,false) only updated one db.mytest.Update({Count: {$gt:6}},{$Set: {name: "ok123"}},true,true) is more than 6 all updated
MONGO Database Commands Simple Learning