MongoDB
 sql >> Database >  >> NoSQL >> MongoDB

Come garantire un'e-mail univoca, userName entrerà in MongoDB usando Mongoose

Ho provato in questo modo e ha funzionato

db.UserSchema = new db.Schema({ userName: {type: String, index: {unique: true, dropDups: true}}, emailId: {type: String, index: {unique: true, dropDups: true}}, password: {type:String, required:true}, contactNumber: String, region: String, isActive:Boolean, lastLoginDateTime:Date });