MONGO Database Commands Simple Learning

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.