Skip to content

toDrizzleKeyset

function toDrizzleKeyset(columns): DrizzleKeyset;

Defined in: pagination-drizzle.ts:47

Create a Drizzle adapter for portable keyset predicates and ordering.

The mapping values can be Drizzle columns or SQL expressions. Keys are the logical cursor keys used by createKeysetSpec; they do not need to match database column names.

Parameter Type
columns DrizzleKeysetColumns

DrizzleKeyset

import { toDrizzleKeyset } from "@xtandard/lib/pagination/drizzle";
const drizzleKeyset = toDrizzleKeyset({
createdAt: posts.createdAt,
id: posts.id,
});
await db
.select()
.from(posts)
.where(drizzleKeyset.where(keyset.where(cursor, direction)))
.orderBy(...drizzleKeyset.orderBy(keyset.orderBy(direction)))
.limit(limit);