datamodel.prisma 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145
  1. type User {
  2. id: ID! @id
  3. email: String! @unique
  4. name: String!
  5. password: String!
  6. resetToken: String
  7. resetTokenExpiry: Float
  8. createdAt: DateTime! @createdAt
  9. comments: [Comment!]!
  10. ratings: [Rating!]!
  11. permissions: [Permission!]! @scalarList(strategy: RELATION)
  12. interests: [String!]! @scalarList(strategy: RELATION)
  13. avatar: Picture
  14. }
  15. enum Permission {
  16. ADMIN
  17. INSTRUCTOR
  18. }
  19. type Training {
  20. id: ID! @id
  21. title: String!
  22. type: TrainingType!
  23. createdAt: DateTime! @createdAt
  24. trainingDate: DateTime!
  25. location: String!
  26. registrations: [User!]!
  27. attendance: Int
  28. ratings: [Rating!]!
  29. published: Boolean!
  30. blocks: [BlockInstance!]! @relation(onDelete: CASCADE)
  31. }
  32. type TrainingType {
  33. id: ID! @id
  34. name: String! @unique
  35. description: String!
  36. }
  37. type Block {
  38. id: ID! @id
  39. title: String!
  40. description: String
  41. duration: Int
  42. format: Format!
  43. rest: Int
  44. tracks: [Track!]!
  45. videos: [String!]! @scalarList(strategy: RELATION)
  46. pictures: [String!]! @scalarList(strategy: RELATION)
  47. blocks: [BlockInstance!] @relation(name: "Instances", onDelete: CASCADE)
  48. parentBlockInstances: [BlockInstance!]! @relation(name: "ParentChild", onDelete: CASCADE)
  49. exercises: [ExerciseInstance!]! @relation(name: "BlockExercises", onDelete: CASCADE)
  50. }
  51. type BlockInstance {
  52. id: ID! @id
  53. block: Block! @relation(name: "ParentChild", onDelete: SET_NULL)
  54. parentBlock: Block @relation(name: "Instances")
  55. parentTraining: Training @relation(link: INLINE)
  56. order: Int!
  57. rounds: Int
  58. variation: String
  59. }
  60. type Format {
  61. id: ID! @id
  62. name: String!
  63. description: String!
  64. }
  65. type File {
  66. id: ID! @id
  67. createdAt: DateTime! @createdAt
  68. updatedAt: DateTime! @updatedAt
  69. path: String!
  70. mimetype: String!
  71. user: User!
  72. thumbnail: String
  73. filename: String!
  74. encoding: String!
  75. size: Int!
  76. comment: String
  77. }
  78. type Track {
  79. id: ID! @id
  80. title: String!
  81. artist: String!
  82. duration: Int!
  83. file: File
  84. link: String
  85. }
  86. type Video {
  87. id: ID! @id
  88. title: String!
  89. description: String!
  90. duration: Int!
  91. file: File
  92. link: String
  93. }
  94. type Picture {
  95. id: ID! @id
  96. title: String!
  97. description: String!
  98. file: File
  99. link: String
  100. }
  101. type Exercise {
  102. id: ID! @id
  103. name: String!
  104. description: String
  105. videos: [String!]! @scalarList(strategy: RELATION)
  106. pictures: [String!]! @scalarList(strategy: RELATION)
  107. targets: [String!]! @scalarList(strategy: RELATION)
  108. baseExercise: [String!]! @scalarList(strategy: RELATION)
  109. parentExerciseInstances: [ExerciseInstance!]!
  110. }
  111. type ExerciseInstance {
  112. id: ID! @id
  113. exercise: Exercise! @relation(link: TABLE)
  114. order: Int!
  115. repetitions: Int
  116. variation: String
  117. parentBlockInstances: Block! @relation(name: "BlockExercises")
  118. }
  119. type Rating {
  120. id: ID! @id
  121. user: User!
  122. value: Int!
  123. comment: String!
  124. createdAt: DateTime! @createdAt
  125. }
  126. type Comment {
  127. id: ID! @id
  128. text: String!
  129. author: User!
  130. createdAt: DateTime! @createdAt
  131. }