I am trying to create and use an enum
type in Mongoose. I checked it out, but I'm not getting the proper result. I'm using enum
in my program as follows:
My schema is:
var RequirementSchema = new mongooseSchema({
status: {
type: String,
enum : ['NEW,'STATUS'],
default: 'NEW'
},
})
But I am little bit confused here, how can I put the value of an enum
like in Java NEW("new")
. How can I save an enum
in to the database according to it's enumerable values. I am using it in express node.js.
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.