I am using mongodb for my application and i am facing a problem like a field is accepting duplicate values as well which i dont want
I want to know how to restrict it
I have followed an approach by specifying unique :true
for a field quesListName
var mongoose = require('mongoose'),
Schema = mongoose.Schema;
var QuestionListSchema = new Schema({
topicName: String,
quesList: {
quesListName: {
type: String,
unique: true
},
by: String
}
});
but still it is accepting the duplicate value
Any help is highly appreciated