VendorExperienceRepository.ts 7.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238
  1. import { PrismaClient, Prisma } from '@prisma/client';
  2. const prisma = new PrismaClient();
  3. interface FindAllParams {
  4. skip?: number;
  5. take?: number;
  6. where?: Prisma.VendorExperienceWhereInput;
  7. orderBy?: Prisma.VendorExperienceOrderByWithRelationInput;
  8. }
  9. const VendorExperienceRepository = {
  10. findAll: async ({ skip, take, where, orderBy }: FindAllParams) => {
  11. return prisma.vendorExperience.findMany({
  12. where,
  13. skip,
  14. take,
  15. orderBy,
  16. select: {
  17. id: true,
  18. vendor: {
  19. select: {
  20. id: true,
  21. name: true,
  22. name_pt: true,
  23. strengths: true,
  24. weaknesses: true,
  25. website: true,
  26. created_by: true,
  27. },
  28. },
  29. status: true,
  30. simrs_type: true,
  31. contract_value_min: true,
  32. contract_value_max: true,
  33. contract_start_date: true,
  34. contract_expired_date: true,
  35. positive_notes: true,
  36. negative_notes: true,
  37. createdAt: true,
  38. updatedAt: true,
  39. },
  40. });
  41. },
  42. countAll: async (where?: Prisma.VendorExperienceWhereInput) => {
  43. return prisma.vendorExperience.count({ where });
  44. },
  45. findById: async (id: string) => {
  46. return prisma.vendorExperience.findFirst({
  47. where: {
  48. id,
  49. deletedAt: null,
  50. },
  51. select: {
  52. id: true,
  53. vendor_id: true,
  54. vendor: {
  55. select: {
  56. id: true,
  57. name: true,
  58. name_pt: true,
  59. strengths: true,
  60. weaknesses: true,
  61. website: true,
  62. created_by: true,
  63. },
  64. },
  65. status: true,
  66. simrs_type: true,
  67. contract_value_min: true,
  68. contract_value_max: true,
  69. contract_start_date: true,
  70. contract_expired_date: true,
  71. positive_notes: true,
  72. negative_notes: true,
  73. createdAt: true,
  74. updatedAt: true,
  75. },
  76. });
  77. },
  78. create: async (data: Prisma.VendorExperienceCreateInput) => {
  79. return prisma.vendorExperience.create({ data });
  80. },
  81. update: async (id: string, data: Prisma.VendorExperienceUpdateInput) => {
  82. return prisma.vendorExperience.update({
  83. where: { id },
  84. data,
  85. });
  86. },
  87. };
  88. export default VendorExperienceRepository;
  89. // const prisma = require('../../prisma/PrismaClient.js');
  90. // const VendorExperienceRepository = {
  91. // findAll: async ({ skip, take, where, orderBy }) => {
  92. // return prisma.vendorExperience.findMany({
  93. // where,
  94. // skip,
  95. // take,
  96. // orderBy,
  97. // select: {
  98. // id: true,
  99. // // hospital: {
  100. // // select: {
  101. // // id: true,
  102. // // name: true,
  103. // // hospital_code: true,
  104. // // type: true,
  105. // // ownership: true,
  106. // // province: {
  107. // // select: {
  108. // // id: true,
  109. // // name: true
  110. // // }
  111. // // },
  112. // // city: {
  113. // // select: {
  114. // // id: true,
  115. // // name: true
  116. // // }
  117. // // },
  118. // // address: true,
  119. // // simrs_type: true,
  120. // // contact: true,
  121. // // image: true,
  122. // // progress_status: true,
  123. // // note: true,
  124. // // created_by: true
  125. // // }
  126. // // },
  127. // vendor: {
  128. // select: {
  129. // id: true,
  130. // name: true,
  131. // name_pt: true,
  132. // strengths: true,
  133. // weaknesses: true,
  134. // website: true,
  135. // created_by: true,
  136. // }
  137. // },
  138. // status: true,
  139. // simrs_type: true,
  140. // contract_value_min: true,
  141. // contract_value_max: true,
  142. // contract_start_date: true,
  143. // contract_expired_date: true,
  144. // positive_notes: true,
  145. // negative_notes: true,
  146. // createdAt: true,
  147. // updatedAt: true,
  148. // },
  149. // });
  150. // },
  151. // countAll: async (where) => {
  152. // return prisma.vendorExperience.count({ where });
  153. // },
  154. // findById: async (id) => {
  155. // return prisma.vendorExperience.findFirst({
  156. // where: {
  157. // id,
  158. // deletedAt: null
  159. // },
  160. // select: {
  161. // id: true,
  162. // // hospital: {
  163. // // select: {
  164. // // id: true,
  165. // // name: true,
  166. // // hospital_code: true,
  167. // // type: true,
  168. // // ownership: true,
  169. // // province: {
  170. // // select: {
  171. // // id: true,
  172. // // name: true
  173. // // }
  174. // // },
  175. // // city: {
  176. // // select: {
  177. // // id: true,
  178. // // name: true
  179. // // }
  180. // // },
  181. // // address: true,
  182. // // simrs_type: true,
  183. // // contact: true,
  184. // // image: true,
  185. // // progress_status: true,
  186. // // note: true,
  187. // // created_by: true
  188. // // }
  189. // // },
  190. // vendor: {
  191. // select: {
  192. // id: true,
  193. // name: true,
  194. // name_pt: true,
  195. // strengths: true,
  196. // weaknesses: true,
  197. // website: true,
  198. // created_by: true,
  199. // }
  200. // },
  201. // status: true,
  202. // simrs_type: true,
  203. // contract_value_min: true,
  204. // contract_value_max: true,
  205. // contract_start_date: true,
  206. // contract_expired_date: true,
  207. // positive_notes: true,
  208. // negative_notes: true,
  209. // createdAt: true,
  210. // updatedAt: true,
  211. // },
  212. // });
  213. // },
  214. // create: async (data) => {
  215. // return prisma.vendorExperience.create({ data });
  216. // },
  217. // update: async (id, data) => {
  218. // return prisma.vendorExperience.update({
  219. // where: { id },
  220. // data
  221. // });
  222. // },
  223. // };
  224. // module.exports = VendorExperienceRepository;