right now I am doing something like: ```export a...
# orm-help
v
right now I am doing something like:
Copy code
export async function getProducts({
  filters,
  page,
  limit,
  orderBy = { Name: "asc" },
  searchTerm = "",
}: {
  filters: string[];
  page: number;
  limit: number;
  orderBy?: Record<string, string>;
  searchTerm: string;
}): Promise<
  Prisma.ProductGetPayload<{
    include: { Category: true };
  }>[]
> {
  const { skip, take } = getItemsPaginated({ page, limit });
  const prismaDBFilters = filters.map((filter) => ({
    Name: { equals: filter },
  }));
  if (prismaDBFilters.length) {
    return await prisma.product.findMany({
      orderBy,
      skip,
      take,
      where: {
        Name: {
          contains: searchTerm,
        },
        Category: {
          OR: prismaDBFilters,
        },
      },
      include: {
        Category: true,
      },
    });
  } else {
    return await prisma.product.findMany({
      orderBy,
      skip,
      take,
      where: {
        Name: {
          contains: searchTerm,
        },
      },
      include: {
        Category: true,
      },
    });
  }
}