📌  相关文章
📜  访问 MongoDb Mongoose Schema 中 Enum 字段的有效值列表 - Javascript 代码示例

📅  最后修改于: 2022-03-11 15:01:17.761000             🧑  作者: Mango

代码示例1
var mongoose = require('./index');

PersonSchema = new mongoose.Schema({
    name: {type: String, required: true},
    gender: {type: String, enum: ['Male', 'Female', 'Others']}
});

var PersonModel = mongoose.model('Person', PersonSchema);

console.log(PersonModel.schema.path('gender').enumValues);

// ['Male', 'Female', 'Others']