Zeichen's backing service for remote storage.
Vous ne pouvez pas sélectionner plus de 25 sujets Les noms de sujets doivent commencer par une lettre ou un nombre, peuvent contenir des tirets ('-') et peuvent comporter jusqu'à 35 caractères.

ColumnTypes.ts 1.2 KiB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. import {
  2. DataType,
  3. INTEGER,
  4. STRING,
  5. TEXT,
  6. DATE,
  7. DATEONLY,
  8. UUIDV4,
  9. } from 'sequelize'
  10. type ModelAttribute = {
  11. allowNull?: boolean,
  12. primaryKey?: boolean,
  13. type: DataType,
  14. }
  15. export interface Model {
  16. tableName?: string,
  17. modelName?: string,
  18. options?: {
  19. timestamps?: boolean,
  20. paranoid?: boolean,
  21. createdAt?: string | boolean,
  22. updatedAt?: string | boolean,
  23. deletedAt?: string | boolean,
  24. },
  25. attributes: Record<string, ModelAttribute>,
  26. }
  27. type IntegerType = typeof INTEGER | ReturnType<typeof INTEGER>
  28. type NumberType = IntegerType
  29. type VarcharType = typeof STRING
  30. type TextType = typeof TEXT | ReturnType<typeof TEXT>
  31. type StringType = VarcharType | TextType
  32. type DateTimeType = typeof DATE
  33. type DateOnlyType = typeof DATEONLY
  34. type DateType = DateTimeType | DateOnlyType
  35. type InferType<V extends DataType> = (
  36. V extends NumberType ? number :
  37. V extends StringType ? string :
  38. V extends DateType ? Date :
  39. V extends typeof UUIDV4 ? string :
  40. unknown
  41. )
  42. export type InferModel<M extends Model> = {
  43. [K in keyof M['attributes']]-?: InferType<M['attributes'][K]['type']>
  44. }
  45. export {
  46. INTEGER,
  47. STRING,
  48. TEXT,
  49. DATEONLY,
  50. DATE,
  51. UUIDV4,
  52. }