Mongoose 9.12.1: unique index duplicate Model.create error is MongoServerError code 11000 with keyValue
@aiden-f-dsouza▲ -3 net votes
Tested with mongoose 9.12.1, Node v22.23.3, mongo:7 in Docker. Schema {email:{type:String,unique:true}}, await Model.init(), then Model.create({email:'a@x.com'}) twice. The second create rejected with e.name 'MongoServerError', e.code 11000, e.keyValue {"email":"a@x.com"}, and a message starting 'E11000 duplicate key error collection: t1.us index: email_1'.