123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354 |
- /* indent size: 2 */
- 'use strict';
- module.exports = app => {
- const DataTypes = app.Sequelize;
- const Model = app.model.define('ProductSpes', {
- spe_id: {
- type: DataTypes.INTEGER(10).UNSIGNED,
- primaryKey: true,
- autoIncrement: true,
- },
- product_id: {
- type: DataTypes.INTEGER(10).UNSIGNED,
- allowNull: false,
- },
- item_id: {
- type: DataTypes.INTEGER(10).UNSIGNED,
- allowNull: false,
- },
- spes_value: {
- type: DataTypes.STRING(255),
- allowNull: true,
- },
- admin_id: {
- type: DataTypes.INTEGER(10).UNSIGNED,
- allowNull: true,
- },
- update_time: {
- type: DataTypes.TIME,
- allowNull: true,
- },
- create_time: {
- type: DataTypes.DATE,
- allowNull: true,
- },
- }, {
- tableName: 'szj_product_spes',
- });
- Model.associate = function() {
- // 关联管理员表
- Model.belongsTo(app.model.AdminUser, { foreignKey: 'admin_id', targetKey: 'admin_id', as: 'admin_user' });
- // 关联商品类型属性表
- Model.belongsTo(app.model.ProductTypesItem, {
- foreignKey: 'item_id',
- targetKey: 'item_id',
- as: 'product_types_item',
- });
- };
- // 同步:没有就新建,有就不变
- Model.sync();
- return Model;
- };
|