File size: 731 Bytes
39ccc4b
 
a3fbcaf
67ea2ab
2a7eb2e
a3fbcaf
 
 
 
 
 
 
 
 
39ccc4b
 
2a7eb2e
80222b4
2a7eb2e
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
"use server";

import prisma from "@/_utils/prisma";

export const getLastLogos = async () => {
  const images = await prisma.logo.findMany({
    select: {
      id: true,
    },
    take: 24,
    orderBy: {
      id: "desc",
    },
  });
  return images.map((image) => image.id);
};

const ITEMS_PER_PAGE = 24;

export const getLogos = async (page: number = 0) => {
  const images = await prisma.logo.findMany({
    select: {
      id: true,
    },
    skip: page * ITEMS_PER_PAGE,
    take: ITEMS_PER_PAGE,
    orderBy: {
      id: "desc",
    },
  });

  const total = await prisma.logo.count();
  const hasMore = total > (page + 1) * ITEMS_PER_PAGE;

  return {
    logos: images.map((image) => image.id),
    hasMore,
  };
};