'use strict'; module.exports = app => { const { INTEGER, STRING, DATE } = app.Sequelize; const QimenApp = app.model.define('qimen_app', { id: { type: INTEGER(11), primaryKey: true, autoIncrement: true, allowNull: false, comment: '应用ID', }, name: { type: STRING(100), allowNull: true, validate: { len: [ 0, 100 ], }, comment: '应用名称', }, app_key: { type: STRING(50), allowNull: true, unique: 'uk_app_key', validate: { len: [ 0, 50 ], }, comment: '应用密钥', }, created_at: { type: DATE, allowNull: false, comment: '创建时间', }, updated_at: { type: DATE, allowNull: false, comment: '更新时间', }, }, { tableName: 'wms_qimen_apps', freezeTableName: true, underscored: true, timestamps: true, createdAt: 'created_at', updatedAt: 'updated_at', comment: '奇门应用配置表', indexes: [ { name: 'uk_app_key', unique: true, fields: [ 'app_key' ], }, { name: 'idx_name', fields: [ 'name' ], }, ], }); // 定义实例方法 QimenApp.prototype.toJSON = function() { const values = { ...this.get() }; return values; }; return QimenApp; };