小编ice*_*awn的帖子

mongodb 3.4.2 InvalidIndexSpecificationOption错误:字段'unique'对于_id索引规范无效

该命令db.testCollection.createIndex( { _id: 1 }, {name: "_id_2", unique: true, background: true} )在mongo版本3.4.2上失败,但不是3.2.11.mongo文档表明版本3.4支持uniquebackground属性.

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)

mongoose mongodb mongodb-indexes

10
推荐指数
1
解决办法
7064
查看次数

标签 统计

mongodb ×1

mongodb-indexes ×1

mongoose ×1