datamodel.prisma 3.3 KB

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