Reputation: 980
I am using the mongoose framework and trying to insert data. This is my schema:
var personSchema = new mongoose.Schema({
"gender": {
type: String,
enum: ["male", "female", "other", "unknown"],
lowercase: false,
},
...
});
I only want to allow case-sensitive values of the name. So the dataset {"gender":"Male"}
should create an error. But in fact, it doesn't matter if I use lowercase: true
or false, it creates the Object and uses the lowercase value of my enum. Only when I delete the lowercase
attribute, then my inserted dataset isn't accepted.
Is there a fix for this problem?
Upvotes: 4
Views: 11289
Reputation: 980
Ok, this is apperently a bug from mongoose. I created a bug report on GitHub: https://github.com/Automattic/mongoose/issues/4622
Upvotes: 6