47 lines
1.1 KiB
JavaScript
47 lines
1.1 KiB
JavaScript
const { DataTypes } = require('sequelize');
|
|
const BaseModel = require('./BaseModel');
|
|
|
|
/**
|
|
* 牛只用途模型
|
|
*/
|
|
class CattleUser extends BaseModel {
|
|
static init(sequelize) {
|
|
return super.init({
|
|
id: {
|
|
type: DataTypes.INTEGER,
|
|
primaryKey: true,
|
|
comment: '用途ID'
|
|
},
|
|
name: {
|
|
type: DataTypes.STRING(100),
|
|
allowNull: false,
|
|
comment: '用途名称'
|
|
},
|
|
description: {
|
|
type: DataTypes.TEXT,
|
|
allowNull: true,
|
|
comment: '用途描述'
|
|
}
|
|
}, {
|
|
sequelize,
|
|
modelName: 'CattleUser',
|
|
tableName: 'cattle_user',
|
|
comment: '牛只用途表',
|
|
timestamps: true,
|
|
createdAt: 'created_at',
|
|
updatedAt: 'updated_at'
|
|
});
|
|
}
|
|
|
|
// 关联关系已在 models/index.js 中定义
|
|
// static associate(models) {
|
|
// // 一个用途可以有多个牛只
|
|
// this.hasMany(models.IotCattle, {
|
|
// foreignKey: 'user_id',
|
|
// as: 'cattle'
|
|
// });
|
|
// }
|
|
}
|
|
|
|
module.exports = CattleUser;
|