carts.js 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. /* indent size: 2 */
  2. module.exports = app => {
  3. const DataTypes = app.Sequelize;
  4. const Model = app.model.define('Carts', {
  5. cart_id: {
  6. type: DataTypes.INTEGER(10).UNSIGNED,
  7. allowNull: false,
  8. primaryKey: true,
  9. autoIncrement: true,
  10. },
  11. product_id: {
  12. type: DataTypes.INTEGER(10).UNSIGNED,
  13. allowNull: true,
  14. },
  15. category_id: {
  16. type: DataTypes.INTEGER(10).UNSIGNED,
  17. allowNull: true,
  18. },
  19. product_count: {
  20. type: DataTypes.INTEGER(10).UNSIGNED,
  21. allowNull: true,
  22. },
  23. is_select: {
  24. type: DataTypes.INTEGER(1).UNSIGNED,
  25. allowNull: true,
  26. },
  27. user_id: {
  28. type: DataTypes.INTEGER(10).UNSIGNED,
  29. allowNull: true,
  30. },
  31. random_key: {
  32. type: DataTypes.STRING(10),
  33. allowNull: true,
  34. },
  35. update_time: {
  36. type: DataTypes.TIME,
  37. },
  38. create_time: {
  39. type: DataTypes.DATE,
  40. allowNull: true,
  41. },
  42. volume: {
  43. type: DataTypes.INTEGER(10).UNSIGNED,
  44. allowNull: false,
  45. },
  46. price: {
  47. type: DataTypes.FLOAT,
  48. allowNull: true,
  49. },
  50. dinning_coin_amount: {
  51. type: DataTypes.INTEGER(10).UNSIGNED,
  52. allowNull: true,
  53. },
  54. dining_partner_id: {
  55. type: DataTypes.INTEGER(8),
  56. allowNull: true,
  57. },
  58. }, {
  59. tableName: 'szj_carts',
  60. });
  61. Model.associate = function() {
  62. // 关联商品表
  63. Model.belongsTo(app.model.Products, { foreignKey: 'product_id', targetKey: 'product_id', as: 'products' });
  64. };
  65. // 同步:没有就新建,有就不变
  66. Model.sync();
  67. return Model;
  68. };