MongoDB
 sql >> Base de Dados >  >> NoSQL >> MongoDB

Como garantir um e-mail exclusivo, userName entrará no MongoDB usando o Mongoose


tentei desta forma e funcionou

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 });