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

Mongo shell "getlasterror" does not return "updatedExisting" via mongos

    • Type: Icon: Bug Bug
    • Resolution: Done
    • Priority: Icon: Minor - P4 Minor - P4
    • 2.1.2
    • Affects Version/s: 2.0.2
    • Component/s: Shell
    • None
    • ALL

      I was testing the "Update if current" in mongo shell, using the documentation on the mongoDB website.

      I tried to duplicate the little code snippet that was there, but the results I got back did not match. I was expecting to see the "updatedExisting" field when i called "getlasterror".

      Here is exactly what i did from the mongoDB shell, along with the output.

      mongos> db.t.insert(

      {sku:'abc',qty:1}

      )
      mongos> db.t.find()

      { "_id" : ObjectId("4f746863fba63782ae1d93a1"), "sku" : "abc", "qty" : 1 }

      mongos> db.t.update({sku:"abc",qty:{$gt:0}}, { $inc :

      { qty : -1 }

      } )
      mongos> db.$cmd.findOne(

      {getlasterror:1}

      )

      { "err" : null, "ok" : 1 }

      mongos> db.t.find()

      { "_id" : ObjectId("4f746863fba63782ae1d93a1"), "sku" : "abc", "qty" : 0 }

      mongos> db.t.update({sku:"abc",qty:{$gt:0}}, { $inc :

      { qty : -1 }

      } )
      mongos> db.$cmd.findOne(

      {getlasterror:1}

      )

      { "err" : null, "ok" : 1 }

      mongos> db.t.find()

      { "_id" : ObjectId("4f746863fba63782ae1d93a1"), "sku" : "abc", "qty" : 0 }

            Assignee:
            eliot Eliot Horowitz (Inactive)
            Reporter:
            nsimmons Nicholas Simmons
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: