User.ts 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. module.exports = app => {
  2. const { STRING, INTEGER, DATE } = app.Sequelize;
  3. const User = app.model.define('users', {
  4. id: {
  5. type: INTEGER,
  6. primaryKey: true,
  7. autoIncrement: true,
  8. notNull: true,
  9. notEmpty: true,
  10. comment: '用户ID',
  11. },
  12. wallet: {
  13. type: STRING(64),
  14. notNull: true,
  15. notEmpty: true,
  16. comment: '钱包地址',
  17. },
  18. level: {
  19. type: INTEGER,
  20. notNull: true,
  21. notEmpty: true,
  22. defaultValue: 0,
  23. comment: '用户等级',
  24. },
  25. hash_rate: {
  26. type: INTEGER,
  27. notNull: true,
  28. notEmpty: true,
  29. defaultValue: 0,
  30. comment: '用户算力',
  31. },
  32. pid: {
  33. type: INTEGER,
  34. notNull: true,
  35. notEmpty: true,
  36. comment: '父级ID',
  37. },
  38. path: {
  39. type: STRING,
  40. notNull: true,
  41. notEmpty: true,
  42. comment: '用户邀请路径',
  43. },
  44. created_at: DATE,
  45. updated_at: DATE,
  46. }, {
  47. indexes: [
  48. {
  49. name: 'I_wallet',
  50. fields: [ 'wallet' ],
  51. using: 'BTREE',
  52. },
  53. {
  54. name: 'I_level',
  55. fields: [ 'level' ],
  56. using: 'BTREE',
  57. },
  58. {
  59. name: 'I_pid',
  60. fields: [ 'pid' ],
  61. using: 'BTREE',
  62. },
  63. {
  64. name: 'I_path',
  65. fields: [ 'path' ],
  66. using: 'BTREE',
  67. },
  68. ],
  69. });
  70. User.sync();
  71. return User;
  72. };