12345678910111213141516171819202122232425262728293031323334353637383940 |
- /* indent size: 2 */
- module.exports = app => {
- const DataTypes = app.Sequelize;
- const Model = app.model.define('Roles', {
- role_id: {
- type: DataTypes.INTEGER(10).UNSIGNED,
- primaryKey: true,
- autoIncrement: true
- },
- role_desc: {
- type: DataTypes.STRING(255),
- },
- role_name: {
- type: DataTypes.STRING(20),
- },
- admin_id: {
- type: DataTypes.INTEGER(10).UNSIGNED,
- },
- update_time: {
- type: DataTypes.TIME
- },
- create_time: {
- type: DataTypes.DATE,
- }
- }, {
- tableName: 'szj_roles'
- });
- Model.associate = function() {
- //关联管理员表
- Model.belongsTo(app.model.AdminUser,{foreignKey:'role_id',targetKey:'role_id',as:'admin_user'});
- //关联管理员表
- Model.belongsTo(app.model.AdminUser,{foreignKey:'admin_id',targetKey:'admin_id',as:'admin_user1'});
- }
- //同步:没有就新建,有就不变
- Model.sync();
- return Model;
- };
|