toPrismaKeyset
function toPrismaKeyset(fields): PrismaKeyset;Defined in: pagination-prisma.ts:97
Create a Prisma adapter for portable keyset predicates and ordering.
This adapter emits plain Prisma where and orderBy objects for scalar
fields. Prisma does not support arbitrary computed SQL expressions in its
typed query API; use toKeysetWhereSql + $queryRawUnsafe for expression
keysets that cannot be represented as scalar fields.
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
fields |
PrismaKeysetFields |
Returns
Section titled “Returns”Example
Section titled “Example”import { toPrismaKeyset } from "@xtandard/lib/pagination/prisma";
const prismaKeyset = toPrismaKeyset({ createdAt: "createdAt", id: "id",});
const page = await prisma.post.findMany({ where: prismaKeyset.where(keyset.where(cursor, direction)), orderBy: prismaKeyset.orderBy(keyset.orderBy(direction)), take: limit,});