|
Currently the RecordStore's duplicate key error message assumes the primary key is always _id. For example, on a collection clustered by ts:
> db.c.count()
|
0
|
> db.c.insertOne({_id:0, ts:1})
|
{ "acknowledged" : true, "insertedId" : 0 }
|
> db.c.insertOne({_id:1, ts:1})
|
WriteError({
|
"index" : 0,
|
"code" : 11000,
|
"errmsg" : "E11000 duplicate key error collection: local.c dup key: { _id: 1 }",
|
"op" : {
|
"_id" : 1,
|
"ts" : 1
|
}
|
}) :
|
The output is misleading: the duplicate key is actually ts, not the reported _id.
Extend it to make the error message meaningful with arbitrary cluster keys.
|