【发布时间】:2016-04-06 05:46:46
【问题描述】:
我想在 ES6 中编写我的猫鼬模型。基本上尽可能替换 module.exports 和其他 ES5 的东西。这是我所拥有的。
import mongoose from 'mongoose'
class Blacklist extends mongoose.Schema {
constructor() {
super({
type: String,
ip: String,
details: String,
reason: String
})
}
}
export default mongoose.model('Blacklist', Blacklist)
我在控制台中看到了这个错误。
if (!('pluralization' in schema.options)) schema.options.pluralization = this.options.pluralization;
^
TypeError: Cannot use 'in' operator to search for 'pluralization' in undefined
【问题讨论】:
-
schema.loadClass(ClassName) mongoosejs.com/docs/advanced_schemas.html
-
检查 loadClass method 的猫鼬模式
标签: javascript node.js mongoose ecmascript-6