123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238 |
- import { PrismaClient, Prisma } from '@prisma/client';
- const prisma = new PrismaClient();
- interface FindAllParams {
- skip?: number;
- take?: number;
- where?: Prisma.VendorExperienceWhereInput;
- orderBy?: Prisma.VendorExperienceOrderByWithRelationInput;
- }
- const VendorExperienceRepository = {
- findAll: async ({ skip, take, where, orderBy }: FindAllParams) => {
- return prisma.vendorExperience.findMany({
- where,
- skip,
- take,
- orderBy,
- select: {
- id: true,
- vendor: {
- select: {
- id: true,
- name: true,
- name_pt: true,
- strengths: true,
- weaknesses: true,
- website: true,
- created_by: true,
- },
- },
- status: true,
- simrs_type: true,
- contract_value_min: true,
- contract_value_max: true,
- contract_start_date: true,
- contract_expired_date: true,
- positive_notes: true,
- negative_notes: true,
- createdAt: true,
- updatedAt: true,
- },
- });
- },
- countAll: async (where?: Prisma.VendorExperienceWhereInput) => {
- return prisma.vendorExperience.count({ where });
- },
- findById: async (id: string) => {
- return prisma.vendorExperience.findFirst({
- where: {
- id,
- deletedAt: null,
- },
- select: {
- id: true,
- vendor_id: true,
- vendor: {
- select: {
- id: true,
- name: true,
- name_pt: true,
- strengths: true,
- weaknesses: true,
- website: true,
- created_by: true,
- },
- },
- status: true,
- simrs_type: true,
- contract_value_min: true,
- contract_value_max: true,
- contract_start_date: true,
- contract_expired_date: true,
- positive_notes: true,
- negative_notes: true,
- createdAt: true,
- updatedAt: true,
- },
- });
- },
- create: async (data: Prisma.VendorExperienceCreateInput) => {
- return prisma.vendorExperience.create({ data });
- },
- update: async (id: string, data: Prisma.VendorExperienceUpdateInput) => {
- return prisma.vendorExperience.update({
- where: { id },
- data,
- });
- },
- };
- export default VendorExperienceRepository;
- // const prisma = require('../../prisma/PrismaClient.js');
- // const VendorExperienceRepository = {
- // findAll: async ({ skip, take, where, orderBy }) => {
- // return prisma.vendorExperience.findMany({
- // where,
- // skip,
- // take,
- // orderBy,
- // select: {
- // id: true,
- // // hospital: {
- // // select: {
- // // id: true,
- // // name: true,
- // // hospital_code: true,
- // // type: true,
- // // ownership: true,
- // // province: {
- // // select: {
- // // id: true,
- // // name: true
- // // }
- // // },
- // // city: {
- // // select: {
- // // id: true,
- // // name: true
- // // }
- // // },
- // // address: true,
- // // simrs_type: true,
- // // contact: true,
- // // image: true,
- // // progress_status: true,
- // // note: true,
- // // created_by: true
- // // }
- // // },
- // vendor: {
- // select: {
- // id: true,
- // name: true,
- // name_pt: true,
- // strengths: true,
- // weaknesses: true,
- // website: true,
- // created_by: true,
- // }
- // },
- // status: true,
- // simrs_type: true,
- // contract_value_min: true,
- // contract_value_max: true,
- // contract_start_date: true,
- // contract_expired_date: true,
- // positive_notes: true,
- // negative_notes: true,
- // createdAt: true,
- // updatedAt: true,
- // },
- // });
- // },
- // countAll: async (where) => {
- // return prisma.vendorExperience.count({ where });
- // },
- // findById: async (id) => {
- // return prisma.vendorExperience.findFirst({
- // where: {
- // id,
- // deletedAt: null
- // },
- // select: {
- // id: true,
- // // hospital: {
- // // select: {
- // // id: true,
- // // name: true,
- // // hospital_code: true,
- // // type: true,
- // // ownership: true,
- // // province: {
- // // select: {
- // // id: true,
- // // name: true
- // // }
- // // },
- // // city: {
- // // select: {
- // // id: true,
- // // name: true
- // // }
- // // },
- // // address: true,
- // // simrs_type: true,
- // // contact: true,
- // // image: true,
- // // progress_status: true,
- // // note: true,
- // // created_by: true
- // // }
- // // },
- // vendor: {
- // select: {
- // id: true,
- // name: true,
- // name_pt: true,
- // strengths: true,
- // weaknesses: true,
- // website: true,
- // created_by: true,
- // }
- // },
- // status: true,
- // simrs_type: true,
- // contract_value_min: true,
- // contract_value_max: true,
- // contract_start_date: true,
- // contract_expired_date: true,
- // positive_notes: true,
- // negative_notes: true,
- // createdAt: true,
- // updatedAt: true,
- // },
- // });
- // },
- // create: async (data) => {
- // return prisma.vendorExperience.create({ data });
- // },
- // update: async (id, data) => {
- // return prisma.vendorExperience.update({
- // where: { id },
- // data
- // });
- // },
- // };
- // module.exports = VendorExperienceRepository;
|