QueryBuilder
QueryBuilder =
object
Defined in: packages/db/src/types.ts:428
Builder for read queries on a single table.
Returned by db.query(table). Provides findMany, findFirst, and paginate methods
that each return an Operation with permission-aware execution.
Example
Section titled “Example”const builder = db.query(posts);
// Fetch all visible postsconst all = await builder.findMany().run({});
// Fetch a single postconst post = await builder.findFirst({ where: eq(posts.id, id) }).run({});
// Paginateconst page = await builder.paginate(params, { orderBy: desc(posts.createdAt) }).run({});Properties
Section titled “Properties”findFirst()
Section titled “findFirst()”findFirst: (
options?) =>Operation<unknown|undefined>
Defined in: packages/db/src/types.ts:432
Returns an Operation that fetches the first matching row, or undefined if none match.
Parameters
Section titled “Parameters”options?
Section titled “options?”Returns
Section titled “Returns”Operation<unknown | undefined>
findMany()
Section titled “findMany()”findMany: (
options?) =>Operation<unknown[]>
Defined in: packages/db/src/types.ts:430
Returns an Operation that fetches multiple rows matching the given options.
Parameters
Section titled “Parameters”options?
Section titled “options?”Returns
Section titled “Returns”Operation<unknown[]>
paginate()
Section titled “paginate()”paginate: (
params,options?) =>Operation<CursorPage<unknown>> |Operation<OffsetPage<unknown>>
Defined in: packages/db/src/types.ts:439
Returns a paginated Operation using either cursor-based or offset-based strategy.
The return type depends on the params.type discriminant: CursorPage for "cursor",
OffsetPage for "offset".
Parameters
Section titled “Parameters”params
Section titled “params”options?
Section titled “options?”Returns
Section titled “Returns”Operation<CursorPage<unknown>> | Operation<OffsetPage<unknown>>