[SERVER-1173] GetLastError After Upsert Should Include New _id Created: 29/May/10  Updated: 12/Jul/16  Resolved: 24/Jun/10

Status: Closed
Project: Core Server
Component/s: None
Affects Version/s: 1.5.3
Fix Version/s: 1.5.4

Type: Improvement Priority: Major - P3
Reporter: Scott Hernandez (Inactive) Assignee: Eliot Horowitz (Inactive)
Resolution: Done Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Related
related to SERVER-5289 _id field not taken from query during... Closed
related to SERVER-1351 GLE upserted _id field should always ... Closed
Participants:

 Description   

The lastErrorObject should contain the newly inserted _id value from the upsert.

> db.test.update(

{foo:1}

, {$set:{blah:1}}, 1, 1)
> db.getLastErrorObj()

{ "err" : null, "updatedExisting" : false, "n" : 1, "ok" : true }

> db.test.find()

{ "_id" : ObjectId("4c0155b806510000000000e7"), "blah" : 1, "foo" : 1 }

I would expect the lastErrorObject to look something like this:

{ "err" : null, "updatedExisting" : false, "n" : 1, "ok" : true, inserted_id: ObjectId("4c0155b806510000000000e7")}

 Comments   
Comment by Eliot Horowitz (Inactive) [ 24/Jun/10 ]

upserted

{
"err" : null,
"updatedExisting" : false,
"upserted" : ObjectId("4c23fd27b49fc37b6b9abeb8"),
"n" : 1,
"ok" : true
}
>

Comment by Scott Hernandez (Inactive) [ 24/Jun/10 ]

What is the name of the field returned? "id" ?

Generated at Thu Feb 08 02:56:17 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.