Uploaded image for project: 'Core Server'
  1. Core Server
  2. SERVER-1092

update using $inc returns value incremented to

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

      Currently we can do:

      foo=db.kg.findAndModify({query:

      {"dogs":2}

      ,update:{$inc:

      {"dogs":1}

      }})

      { "_id" : ObjectId("4bc665954c25a502cc9c76ef"), "dogs" : 2 }

      foo

      { "_id" : ObjectId("4bc665954c25a502cc9c76ef"), "dogs" : 2 }

      db.kg.find()

      { "_id" : ObjectId("4bc665954c25a502cc9c76ef"), "dogs" : 3 }

      I think this would be nicer:

      foo=db.kg.update({},{$inc:{"dogs":1}} )
      foo

      {"dogs":4}

      and perhaps even:

      foo=db.kg.update({},{$inc{"dogs":1}},{$inc{"cats":1}})
      foo

      {"dogs":5,"cats":2}

      Returning the incremented value allows applications to use the newly generated value

            Assignee:
            eliot Eliot Horowitz (Inactive)
            Reporter:
            kgorman Kenny Gorman
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: