[SERVER-5441] Mongo shell "getlasterror" does not return "updatedExisting" via mongos Created: 29/Mar/12 Updated: 11/Jul/16 Resolved: 04/Jun/12 |
|
| Status: | Closed |
| Project: | Core Server |
| Component/s: | Shell |
| Affects Version/s: | 2.0.2 |
| Fix Version/s: | 2.1.2 |
| Type: | Bug | Priority: | Minor - P4 |
| Reporter: | Nicholas Simmons | Assignee: | Eliot Horowitz (Inactive) |
| Resolution: | Done | Votes: | 0 |
| Labels: | None | ||
| Remaining Estimate: | Not Specified | ||
| Time Spent: | Not Specified | ||
| Original Estimate: | Not Specified | ||
| Issue Links: |
|
||||
| Operating System: | ALL | ||||
| Participants: | |||||
| Description |
|
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.update({sku:"abc",qty:{$gt:0}}, { $inc : { qty : -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 } } ) ) { "err" : null, "ok" : 1 }mongos> db.t.find() { "_id" : ObjectId("4f746863fba63782ae1d93a1"), "sku" : "abc", "qty" : 0 } |
| Comments |
| Comment by auto [ 04/Jun/12 ] | |
|
Author: {u'login': u'erh', u'name': u'Eliot Horowitz', u'email': u'eliot@10gen.com'}Message: | |
| Comment by Nicholas Simmons [ 30/Mar/12 ] | |
|
Doing both operations on a single line did the trick. Thanks! | |
| Comment by Eliot Horowitz (Inactive) [ 30/Mar/12 ] | |
|
The problem is the shell is implicitly calling it changing state (which its not supposed to do). try this on a single line
|