sys_user.js 1.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. const { DataTypes } = require('sequelize');
  2. const connect = require('./connect');
  3. /*
  4. type: DataTypes.STRING,
  5. allowNull: false,
  6. defaultValue:'',
  7. comment: '名',
  8. */
  9. const model = connect.define(
  10. __filename.slice(__dirname.length + 1).replace('.js', ''),
  11. {
  12. id: {
  13. type: DataTypes.BIGINT,
  14. autoIncrement: true,
  15. primaryKey: true,
  16. field: 'user_id',
  17. comment: 'id',
  18. },
  19. login: {
  20. type: DataTypes.STRING(30),
  21. allowNull: false,
  22. field: 'user_name',
  23. defaultValue: '',
  24. comment: '名',
  25. },
  26. phoneNumber: {
  27. type: DataTypes.STRING(11),
  28. field: 'phonenumber',
  29. comment: '头像',
  30. },
  31. userType: {
  32. type: DataTypes.STRING(2),
  33. field: 'user_type',
  34. comment: '交易类型(00买家 01卖家 02两者都是)',
  35. },
  36. },
  37. {
  38. comment: '用户',
  39. timestamps: false,
  40. hooks: {
  41. beforeFind(option) {
  42. if (!option.order) {
  43. option.order = [['id', 'desc']];
  44. }
  45. },
  46. },
  47. }
  48. );
  49. module.exports = model;