该命令db.testCollection.createIndex( { _id: 1 }, {name: "_id_2", unique: true, background: true} )在mongo版本3.4.2上失败,但不是3.2.11.mongo文档表明版本3.4支持unique和background属性.
Mongo 3.4.2失败了......
> use testDB
switched to db testDB
> db.testCollection.createIndex( { _id: 1 }, {name: "_id_2", unique: true, background: true} )
{
"ok" : 0,
"errmsg" : "The field 'unique' is not valid for an _id index specification. Specification: { ns: \"testDB.testCollection\", v: 1, key: { _id: 1.0 }, name: \"_id_2\", unique: true, background: true }",
"code" : 197,
"codeName" : …Run Code Online (Sandbox Code Playgroud)