I am implementing an API for a task management and has two endpoints users and tasks. The schema design for the 'users' looks like:
// Define our user schema
var userSchema = new mongoose.Schema({
name: {
type:String,
required: true
},
email: {
type: String,
required: true
},
pendingTasks: [String],
dateCreated: {
type: Date,
default: Date.now }
});
My question is, how can I make the email for each data to be unique? (Not allowing multiple users with the same email)