有什么方法可以访问装载了猫鼬的ES6类的静态吸气剂?
在下面的代码中,我想通过猫鼬模型访问静态获取器“ STATUS”。
const STATUS = {
PRE_ACTIVE: 'pre-active',
LIVE: 'live',
};
class Student {
static get STATUS() {
return STATUS;
}
static attributes() {
return {
name: {type: String, required: true},
lastName: {type: String, required: true},
language: {type: String, required: true},
gender: {type: String, required: true},
}
}
get fullName() {
return `${this.name}_${this.lastName}`;
}
}
const schema = new Schema(Student.attributes(), {timestamps: true});
schema.loadClass(Student);
const StudentMongoose = mongoose.model('Student', schema);
StudentMongoose.find({}); // -> OK
const instance = new StudentMongoose({name: 'John', lastName: 'Doe', language: 'en', gender: 'male'});
instance.fullName; // -> OK
StudentMongoose.attributes(); // -> OK
StudentMongoose.STATUS; // -> NOK