Using a unique constraint in Mongoose like:
email: { type:String, unique:true }
doesn't seem to work. I can save several users with the same email.
Is there something I need to do to create a unique index?
Unique indexes are not supported today, in the MongoDB API for Cosmos DB. You cannot specify unique:true
when creating an index.
You'd need to implement this in your app tier.
EDIT - As pointed out, this was officially released as of November 2017, with the MongoDB API.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With