ORM OpenRecord
TypeError: User.create is not a function
)当我执行以下操作时:
await User.create(req.body.data)
当我登录用户时,我得到以下信息:
[Function: User]
数据库配置:
//config/database/openRecord.js
/** more code above */
let store = new Store({
database,
user,
password,
host,
autoConnect: true,
autoAttributes: true,
models: require("../../app/models/models")
});
//app/models/models.js
module.exports = [
require("./user")
]
型号:
//app/models/user.js
const Store = require('openrecord/store/mysql');
class User extends Store.BaseModel {
static definition(){
this.validatePresenceOf(
'first_name', 'last_name', 'email', 'password'
);
this.validatesConfirmationOf('password');
this.validateFormatOf('email', 'email');
}
fullName(){
return `${this.first_name} ${this.last_name}`
}
}
module.exports = User;
当我以正确的方式清楚地定义了我的对象时,为什么会抛出错误?
openrecord github link
openrecord website documentation