Skip to content

buildRegistryReadHandles

buildRegistryReadHandles<TRegistry>(registry, client?): object

Defined in: packages/client/src/index.ts:3666

The tab-side READ handles a worker-attached client exposes (ADR-0032 S2/decision 4): a Drizzle instance plus the registry views. createSyncClient’s SAME builders, so a query built on either client compiles identically. The client argument is the executor Drizzle runs against:

  • Omit it (the default {} stub) for a BUILD-ONLY instance — Drizzle only compiles to SQL (.toSQL()) and the stub is never invoked; used where execution happens elsewhere (e.g. the live-rows bridge).
  • Pass a ClientPGlite-shaped BRIDGE executor (its query routes to the worker’s guardedQuery RPC) so that awaiting a builder executes through the bridge and Drizzle’s own result mapping (relational/nested queries included) runs on the tab — the one-shot read path attachSyncClient wires (ADR-0032 decision 4).

TRegistry extends SyncTableRegistry

TRegistry

ClientPGlite = ...

drizzle: PgliteDatabase<ExtractTablesWithRelations<{ }, RegistryTables<TRegistry>>>

drizzleFor: (client) => PgliteDatabase<ExtractTablesWithRelations<{ }, RegistryTables<TRegistry>>>

A drizzle-database FACTORY over this registry’s schema (ADR-0032 decision 4): (client) => db, reusing the schema + relations computed ONCE here so a caller can cheaply build additional per-executor databases without recomputing them. attachSyncClient uses it to give each queryRaw/queryRawRow its OWN bridge executor carrying that call’s use — a scoped db, never a shared mutable stash (no read races).

ClientPGlite

PgliteDatabase<ExtractTablesWithRelations<{ }, RegistryTables<TRegistry>>>

views: RegistryViews<TRegistry>