dict.ts 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. import {
  2. Model,
  3. DataTypes,
  4. CreationOptional,
  5. InferAttributes,
  6. InferCreationAttributes,
  7. } from 'sequelize';
  8. import sequelize from '../sequelizeInstance';
  9. class Dict extends Model<
  10. // eslint-disable-next-line no-use-before-define
  11. InferAttributes<Dict>,
  12. // eslint-disable-next-line no-use-before-define
  13. InferCreationAttributes<Dict>
  14. > {
  15. declare id: CreationOptional<number>;
  16. declare key: string;
  17. declare val: string;
  18. declare createdAt: CreationOptional<Date>;
  19. declare updatedAt: CreationOptional<Date>;
  20. }
  21. Dict.init(
  22. {
  23. id: {
  24. type: DataTypes.INTEGER,
  25. autoIncrement: true,
  26. primaryKey: true,
  27. },
  28. key: {
  29. type: DataTypes.STRING,
  30. allowNull: false,
  31. },
  32. val: {
  33. type: DataTypes.STRING,
  34. allowNull: false,
  35. },
  36. createdAt: DataTypes.DATE,
  37. updatedAt: DataTypes.DATE,
  38. },
  39. {
  40. sequelize,
  41. modelName: 'Dict',
  42. underscored: true,
  43. tableName: 'dict',
  44. }
  45. );
  46. export type DictCreationAttributes = InferCreationAttributes<
  47. Dict,
  48. { omit: 'id' | 'createdAt' | 'updatedAt' }
  49. >;
  50. export default Dict;