How to Create and Use Enum in Mongoose
From the docs
Mongoose has several inbuilt validators. Strings have enum as one of the validators.So enum creates a validator and checks if the value is given in an array.E.g:
var userSchema = new mongooseSchema({ userType: { type: String, enum : ['user','admin'], default: 'user' },})