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.
This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.
const { DataTypes } = require ( 'sequelize' ) ;
const { sequelize } = require ( '../config/db' ) ;
const Product = sequelize . define ( 'Product' , {
id : {
type : DataTypes . INTEGER ,
primaryKey : true ,
autoIncrement : true ,
comment : '商品ID'
} ,
name : {
type : DataTypes . STRING ( 100 ) ,
allowNull : false ,
comment : '商品名称'
} ,
description : {
type : DataTypes . TEXT ,
allowNull : true ,
comment : '商品描述'
} ,
price : {
type : DataTypes . DECIMAL ( 10 , 2 ) ,
allowNull : false ,
comment : '商品价格'
} ,
stock : {
type : DataTypes . INTEGER ,
defaultValue : 0 ,
comment : '库存数量'
} ,
category : {
type : DataTypes . STRING ( 50 ) ,
allowNull : true ,
comment : '商品分类'
} ,
imageUrl : {
type : DataTypes . STRING ( 255 ) ,
allowNull : true ,
comment : '商品图片URL'
} ,
status : {
type : DataTypes . TINYINT ,
defaultValue : 1 ,
comment : '状态: 1-上架, 0-下架'
} ,
createdAt : {
type : DataTypes . DATE ,
allowNull : false ,
comment : '创建时间'
} ,
updatedAt : {
type : DataTypes . DATE ,
allowNull : false ,
comment : '更新时间'
}
} , {
tableName : 'products' ,
timestamps : false ,
underscored : true , // 自动将驼峰命名转换为下划线命名
paranoid : false ,
charset : 'utf8mb4' ,
collate : 'utf8mb4_unicode_ci' ,
freezeTableName : true ,
syncOnAssociation : false ,
} ) ;
module . exports = Product ;