私はマングースモデルをES6に書いています。可能であれば、基本的にmodule.exports
と他のES5を置き換えてください。ここに私が持っているものがあります。ES6/ES2015でマングースモデルを書くには
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(クラス名) http://mongoosejs.com/docs/advanced_schemas.html –