/* indent size: 2 */ module.exports = app => { const DataTypes = app.Sequelize; const Model = app.model.define('Articles', { article_id: { type: DataTypes.INTEGER(10).UNSIGNED, primaryKey: true, autoIncrement: true }, article_title: { type: DataTypes.STRING(200), }, article_desc: { type: DataTypes.STRING(255), }, article_content: { type: DataTypes.TEXT, }, article_image: { type: DataTypes.STRING(255), }, article_type: { type: DataTypes.INTEGER(1).UNSIGNED, }, category_id: { type: DataTypes.INTEGER(10).UNSIGNED, }, article_tags: { type: DataTypes.STRING(255), }, article_status: { type: DataTypes.INTEGER(1).UNSIGNED, }, article_author: { type: DataTypes.STRING(100), }, article_views: { type: DataTypes.INTEGER(10).UNSIGNED, }, article_template_info: { type: DataTypes.STRING(255), }, article_recommend: { type: DataTypes.INTEGER(1).UNSIGNED, }, article_template_list: { type: DataTypes.STRING(255), }, article_sort: { type: DataTypes.INTEGER(10).UNSIGNED, }, view_auth: { type: DataTypes.INTEGER(1).UNSIGNED, }, admin_id: { type: DataTypes.INTEGER(10).UNSIGNED, }, update_time: { type: DataTypes.TIME }, create_time: { type: DataTypes.DATE, } }, { tableName: 'szj_articles' }); Model.associate = function() { //关联角色表 Model.belongsTo(app.model.AdminUser,{foreignKey:'admin_id',targetKey:'admin_id',as:'admin_user'}); //关联文章分类表 Model.belongsTo(app.model.ArticlesCategory,{foreignKey:'category_id',targetKey:'category_id',as:'category'}); } //同步:没有就新建,有就不变 Model.sync(); return Model; };