FS1360472174 / nosql-mongo

mongo knowledge
4 stars 4 forks source link

mongo unique 索引 #44

Open FS1360472174 opened 6 years ago

FS1360472174 commented 6 years ago

If a document does not have a value for the indexed field in a unique index, the index will store a null value for this document. Because of the unique constraint, MongoDB will only permit one document that lacks the indexed field. If there is more than one document without a value for the indexed field or is missing the indexed field, the index build will fail with a duplicate key error.

不可以有多个字段不存在