db.testCollection.createIndex({ _id: 1 }, {name: "_id_2", unique: true, background: true})
은 mongo 버전 3.4.2에서는 실패하지만 3.2.11에서는 실패합니다. mongo 문서는 버전 3.4가 unique
및 background
속성을 모두 지원함을 나타냅니다. 몽고의 3.4.2에 실패mongodb 3.4.2 InvalidIndexSpecificationOption 오류 : '고유'필드가 _id 인덱스 지정에 유효하지 않습니다.
...
> 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" : "InvalidIndexSpecificationOption"
}
>
몽고 3.2.11 작품 ...
> use testDB
switched to db testDB
> db.testCollection.createIndex({ _id: 1 }, {name: "_id_2", unique: true, background: true})
{
"createdCollectionAutomatically" : false,
"numIndexesBefore" : 1,
"numIndexesAfter" : 1,
"note" : "all indexes already exist",
"ok" : 1
}
>
사람이 주위에 일을 알고?
우리는 Mongoose 인덱스를 생성하기 위해 Mongoose Node.js 래퍼를 사용하고 있으므로 unique
및 background
속성을 추가하지 않는 것은 옵션이 아닙니다.
건배!
에드 독특한 여기에 문제가되지 않는다는 것을
감사합니다 .Jussi, 그게 전부입니다. 중복 인덱싱 요청을 지적한 3.2.11의 메모를 읽지 않았습니다. 당신이 지적 했으니까요. – icedawn