db/db_pglet.ts

pglet driver adapter for Db.

Provides create_pglet_instance(), which loads @fuzdev/pglet-wasm on demand and creates an in-memory instance with PGLET_COERCION, the value coercion every fuz_app pglet instance is created with, and create_pglet_db_driver() to construct a Db backed by one. The package is imported dynamically, so it stays an optional peer.

view source

Declarations
#

3 declarations

create_pglet_db_driver
#

db/db_pglet.ts view source

(pglet: PgletDb): DbDriverResult import {create_pglet_db_driver} from '@fuzdev/fuz_app/db/db_pglet.js';

Create a Db backed by a pglet instance.

Named _driver to stay clear of @fuzdev/pglet-wasm's own create_pglet_db, which creates the instance this wraps. Create it with create_pglet_instance (or with PGLET_COERCION) so it reads values as the other drivers do.

pglet

a @fuzdev/pglet-wasm instance

type PgletDb

returns

DbDriverResult

the Db instance and a close callback bound to pglet.close()

create_pglet_instance
#

db/db_pglet.ts view source

(): Promise<PgletDb> import {create_pglet_instance} from '@fuzdev/fuz_app/db/db_pglet.js';

Create an in-memory pglet instance with PGLET_COERCION.

Loads @fuzdev/pglet-wasm on demand and awaits its init() — a no-op on the package's Node entry, where the wasm loads at import; the browser entry loads it here.

returns

Promise<PgletDb>

a fresh, empty instance; wrap it with create_pglet_db_driver

PGLET_COERCION
#

db/db_pglet.ts view source

CoercionOptions import {PGLET_COERCION} from '@fuzdev/fuz_app/db/db_pglet.js';

The value coercion fuz_app creates every pglet instance with.

The adapter defaults int8 to bigint; fuz_app reads int8 as a JS number on every driver (register_pg_type_parsers for pg, PGlite's own default), so AuditLogEvent.seq and friends validate identically across drivers.

Depends on
#

Imported by
#