PostgreSQLProviderclass

new PostgreSQLProvider<I, T>()
Return
PostgreSQLProvider<I, T>
Abstract PostgreSQL provider with JSONB function support for nested keys, array containment, and array mutations.

Abstract PostgreSQL provider with JSONB function support for nested keys, array containment, and array mutations.

The abstract SQL provider for PostgreSQL. PostgreSQLProvider extends SQLProvider with PostgreSQL-specific behaviour: the data column is jsonb NOT NULL, generated columns use the #>> operator with a cast, and compatible numeric/string column type changes are applied in place with ALTER COLUMN TYPE.

It is abstract — a concrete subclass implements exec() against a specific PostgreSQL driver.

Usage

ts
import { PostgreSQLProvider } from "shelving/db";

class BunPostgreSQLProvider extends PostgreSQLProvider {
  constructor(private sql: Bun.SQL) { super(); }
  async exec(strings, ...values) {
    return this.sql(strings, ...values);
  }
}

Pair it with PostgreSQLMigrator to create and alter tables to match your collection schemas. A ready-made provider is available in the shelving/bun module.

Examples

class MyProvider extends PostgreSQLProvider { async exec(strings, ...values) { ... } }
 const item = await new MyProvider().getItem(collection, "abc");