Uploaded image for project: 'Documentation'
  1. Documentation
  2. DOCS-505

v2.2 shell has an improved update() API

    XMLWordPrintableJSON

Details

    • Icon: Improvement Improvement
    • Resolution: Done
    • Icon: Major - P3 Major - P3
    • None
    • None
    • None
    • None

    Description

      In the v2.2 shell, update()'s third argument can be a document, in which case the fields in the document specify whether to do upsert or multi. These should be doc'd here:

      http://docs.mongodb.org/manual/reference/method/db.collection.update/

      Examples:

      // Do an upsert.
      db.foo.update( {name:"Smith"}, {$set:{age:30}}, {upsert:true})
      // Do a multi-update
      db.foo.update( {age:{$lt:30}}, {$inc:{salary:10000}}, {multi:true});

      This new API is considerably easier to present to people and slightly less error prone than the pre-v2.2 optional-positional-boolean interface.

      Attachments

        Activity

          People

            kay.kim@mongodb.com Kay Kim (Inactive)
            richard.kreuter Richard Kreuter (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            5 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:
              11 years, 21 weeks ago