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:

const userSchema = new mongoose.Schema({
   userType: {
        type: String,
        enum : ['user','admin'],
        default: 'user'
    },
})


Let say we have a enum Role defined by

export enum Role {
  ADMIN = 'ADMIN',
  USER = 'USER'
}

We can use it as type like:

{
    type: String,
    enum: Role,
    default: Role.USER,
}

The enums here are basically String objects. Change the enum line to enum: ['NEW', 'STATUS'] instead. You have a typo there with your quotation marks.