-
-
Couldn't load subscription status.
- Fork 3.9k
Closed
Labels
docsThis issue is due to a mistake or omission in the mongoosejs.com documentationThis issue is due to a mistake or omission in the mongoosejs.com documentation
Milestone
Description
Fields with 'unique: true' create an index in MongoDB.
However, if a field also has 'lowercase: true', the index results in a 'duplicate key' error when updating an object using a different case
Schema: Person
name: { type: String, unique: true, lowercase: true }
create Person( name="Mike" ) => ok, name converted to 'mike'
findOneAndUpdate( { name: "Mike" }, { upsert: true } ) => Fails, duplicate key "mike"
The issue can be solved by enabling collation for the index, strength=1 to ignore case
Metadata
Metadata
Assignees
Labels
docsThis issue is due to a mistake or omission in the mongoosejs.com documentationThis issue is due to a mistake or omission in the mongoosejs.com documentation