Does Azure Cosmos DB not support MongoDB/Mongoose unique index?

Viewed 1907

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?

2 Answers

This might because your collection already has duplicated values for the field you specified. You need to delete duplicates or create a new database to enable unique index.

Related