The WriteResult from an upsert displays in the shell like so:
res = db.c.update(..., ..., {upsert: true})
printjson(res)
{
"nMatched" : 0,
"nUpserted" : 1,
"nModified" : 0,
"_id" : ObjectId("5ca4b9271da31f1c4f6cc755")
}
However attempting to access the _id returns undefined:
printjson(res._id) undefined
The returned _id can be accessed as res.getUpsertedId()._id, but the value printed for res and the documentation indicate that it should be available as res._id.