SalesRepository.ts 1008 B

12345678910111213141516171819202122232425262728293031323334353637383940
  1. import { create } from 'domain';
  2. import prisma from '../../prisma/PrismaClient';
  3. import { Prisma } from '@prisma/client';
  4. interface FindAllParams {
  5. skip?: number;
  6. take?: number;
  7. where?: Prisma.UserKeycloakWhereInput;
  8. orderBy?: Prisma.UserKeycloakOrderByWithRelationInput;
  9. }
  10. const SalesRepository = {
  11. findAll: async ({ skip, take, where = {} }: FindAllParams) => {
  12. return prisma.userKeycloak.findMany({
  13. where: {
  14. ...where,
  15. role: 'sales',
  16. },
  17. skip,
  18. take,
  19. select: {
  20. id: true,
  21. fullname: true,
  22. phone: true,
  23. role: true,
  24. },
  25. });
  26. },
  27. countAll: async (where: Prisma.UserKeycloakWhereInput = {}): Promise<number> => {
  28. return prisma.userKeycloak.count({
  29. where: {
  30. ...where,
  31. role: 'sales',
  32. }
  33. });
  34. },
  35. };
  36. export default SalesRepository;