postgres function

Database<Postgres> postgres(
  1. PostgresOptions options, {
  2. void onQuery(
    1. QueryEvent
    )?,
  3. void onAcquire(
    1. AcquisitionEvent
    )?,
  4. void onDecode(
    1. DecodeEvent
    )?,
})

Creates a typed database that owns a lazily connected PostgreSQL pool.

Returns synchronously after validating options. A successful return does not prove the server is reachable: authentication, TLS and network failures are reported when an operation first acquires a connection. Execute an explicit query if application startup must verify connectivity.

onAcquire includes pool lease acquisition; onQuery and onDecode observe runtime SQL and result decoding. Await Database.close to close the owned pool. Creating the database does not generate or apply a schema.

Implementation

Database<Postgres> postgres(
  PostgresOptions options, {
  void Function(QueryEvent)? onQuery,
  void Function(AcquisitionEvent)? onAcquire,
  void Function(DecodeEvent)? onDecode,
}) => Database(
  PostgresDriver(options),
  onQuery: onQuery,
  onAcquire: onAcquire,
  onDecode: onDecode,
);