- Node Version:V8.9.4
- Egg Version:2.2.1
- Plugin Name:egg-sequelize
- Plugin Version:3.1.0
- Platform:MacOS
- Mini Showcase Repository:
config/config.default.js
module.exports = appInfo => {
return {
keys:'*******',
sequelize: {
dialect: 'mssql',
database: 'dataName',
host: '127.0.0.1',
port: '1433',
username: 'uname',
password: 'userpwd'
}
}
}
config/plugin.js
module.exports = {
sequelize:{
enable: true,
package: 'egg-sequelize',
},
}
app/model/jianyi.js
'use strict';
module.exports = app => {
console.log(app.Sequelize);//输出undefined
const { STRING, INTEGER, DATE} = app.Sequelize;
const Jiangyi = app.model.define('jiangyi', {
id: {
type: INTEGER,
primaryKey: true,
autoIncrement: true,
},
kemu: INTEGER
});
return Jiangyi;
};
error:TypeError: Cannot destructure property STRING of 'undefined' or 'null'.
config/config.default.js
config/plugin.js
app/model/jianyi.js
error:TypeError: Cannot destructure property
STRINGof 'undefined' or 'null'.