/* indent size: 2 */ // eslint-disable-next-line strict module.exports = app => { const DataTypes = app.Sequelize; const Model = app.model.define('Carts', { cart_id: { type: DataTypes.INTEGER(10).UNSIGNED, allowNull: false, primaryKey: true, autoIncrement: true, }, product_id: { type: DataTypes.INTEGER(10).UNSIGNED, allowNull: true, }, category_id: { type: DataTypes.INTEGER(10).UNSIGNED, allowNull: true, }, pid: { type: DataTypes.INTEGER(4).UNSIGNED, allowNull: true, }, product_count: { type: DataTypes.INTEGER(10).UNSIGNED, allowNull: true, }, is_select: { type: DataTypes.INTEGER(1).UNSIGNED, allowNull: true, }, user_id: { type: DataTypes.INTEGER(10).UNSIGNED, allowNull: true, }, random_key: { type: DataTypes.STRING(10), allowNull: true, }, update_time: { type: DataTypes.TIME, }, create_time: { type: DataTypes.DATE, allowNull: true, }, volume: { type: DataTypes.INTEGER(10).UNSIGNED, allowNull: false, }, price: { type: DataTypes.FLOAT, allowNull: true, }, dinning_coin_amount: { type: DataTypes.INTEGER(10).UNSIGNED, allowNull: true, }, dining_partner_id: { type: DataTypes.INTEGER(8), allowNull: true, }, }, { tableName: 'szj_carts', }); Model.associate = function() { // 关联商品表 Model.belongsTo(app.model.Products, { foreignKey: 'product_id', targetKey: 'product_id', as: 'products' }); }; // 同步:没有就新建,有就不变 Model.sync(); return Model; };