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?
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?
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.