mongoose model type enum code example
Example 1: enum in mongoose
var userSchema = new mongooseSchema({
userType: {
type: String,
enum : ['user','admin'],
default: 'user'
},
})
Example 2: mongoose model enum
enum Role {
ADMIN = 'ADMIN',
USER = 'USER'
}
{
type: String,
enum: Role,
default: Role.USER,
}