You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
56 lines
1.6 KiB
56 lines
1.6 KiB
import { Sequelize, DataTypes, Optional, Model } from "sequelize"
|
|
|
|
interface ColorCateAttributes {
|
|
id: number
|
|
name: string
|
|
alias: string
|
|
describe: string
|
|
|
|
createdAt?: Date
|
|
updatedAt?: Date
|
|
deletedAt?: Date
|
|
}
|
|
|
|
export interface ColorCateInput extends Optional<ColorCateAttributes, "id" | "alias" | "describe"> {}
|
|
export interface ColorCateOutput extends Required<ColorCateAttributes> {}
|
|
export type TColorCateModel = ReturnType<typeof ColorCateModel>
|
|
|
|
export default function ColorCateModel(sequelize: Sequelize) {
|
|
interface ColorCateInstance extends Model<ColorCateAttributes, ColorCateInput>, ColorCateAttributes {}
|
|
const ColorCate = sequelize.define<ColorCateInstance>(
|
|
"color_cate",
|
|
{
|
|
id: {
|
|
type: DataTypes.INTEGER,
|
|
autoIncrement: true,
|
|
primaryKey: true,
|
|
},
|
|
name: {
|
|
type: DataTypes.STRING,
|
|
allowNull: false,
|
|
},
|
|
alias: {
|
|
type: DataTypes.STRING,
|
|
},
|
|
describe: {
|
|
type: DataTypes.STRING,
|
|
},
|
|
},
|
|
{
|
|
underscored: true,
|
|
deletedAt: true,
|
|
paranoid: true,
|
|
timestamps: true,
|
|
},
|
|
)
|
|
// 覆盖Color的toJSON方法
|
|
ColorCate.prototype.toJSON = function () {
|
|
const values = Object.assign({}, this.get()) as ColorCateAttributes
|
|
delete values.deletedAt
|
|
return values
|
|
}
|
|
ColorCate.associate = function (models) {
|
|
|
|
}
|
|
return ColorCate
|
|
}
|
|
|