allo - i'm looking to use <cursor pagination> with...
# orm-help
j
allo - i'm looking to use cursor pagination with a list of chronological results (oldest first). i think i want to do something like:
Copy code
await prisma.thing.findMany({
          take: perPage,
          orderBy: {
            createdAt: "desc",
          },
          skip: cursor ? 1 : undefined,
          cursor: {
            createdAt: cursor,
          },
        }),
...but prisma doesn't like this because
createdAt
isn't a unique field alternatively, i could use
id
as the cursor like in the example, but i am using `cuid`s:
Copy code
model Thing {
  id                 String       @id @default(cuid())
  // other stuff...
  createdAt          DateTime     @default(now())
  updatedAt          DateTime     @updatedAt
}
what's the best approach?
r
@Jaye 👋
cuid
follows a specific order so it should work fine 🙂