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

v2.2 shell has an improved update() API

    • Type: Icon: Task Task
    • Resolution: Done
    • Priority: Icon: Major - P3 Major - P3
    • None
    • Affects Version/s: None
    • Component/s: None
    • Labels:
      None

      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.

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

              Created:
              Updated:
              Resolved:
              11 years, 34 weeks, 1 day ago