OptionalconnectionPostgreSQL connection string (e.g., 'postgresql://user:pass@host:5432/dbname')
OptionalhostHost name or IP address (default: localhost)
OptionalportPort number (default: 5432)
OptionaldatabaseDatabase name
OptionaluserUsername for authentication
OptionalpasswordPassword for authentication
OptionalsslEnable SSL/TLS connection (recommended for remote)
OptionalmaxConnection pool size (default: 10)
OptionalminMinimum pool size (default: 0)
OptionalidleIdle timeout in ms (default: 10000)
OptionalconnectionConnection timeout in ms (default: 0 = no timeout)
Optionalapplication_Application name for connection tracking
Optionalstatement_Statement timeout in ms (0 = no timeout)
Optionalquery_Query timeout in ms (0 = no timeout)
OptionalallowLet Node exit while every connection in the pool is idle (pg's
allowExitOnIdle). Default: false, so idle connections keep the process
running until idleTimeoutMillis closes them or close() ends the pool.
OptionaltypeHow this pool's connections decode the column types whose pg defaults
surprise JavaScript code, through pg's per-client type parsers. Each field
left out keeps pg's default. A value it does not know fails open(). A pool
of the caller's decodes with the types it was made with, so this cannot
be given with pool.
OptionalsegmentA schema of its own for the adapter's tables. Every connection of the
adapter's pool starts with search_path set to the segment, then
public, so the tables it creates without a schema land in the segment,
and the types, functions and operators of extensions in public
(pgvector's vector, <->) still resolve. open() creates the schema
when it is missing, and a CREATE EXTENSION that names no schema installs
the extension where it would without a segment, in public.
open() fails when the segment is not the current schema of its first
connection: PostgreSQL leaves a schema the role has no USAGE privilege on
out of the search_path without a word (an existing schema another role
made), and a pooler that drops startup options leaves it out too. The
role needs USAGE and CREATE on the segment's schema.
A name the segment does not hold falls through to public: create a
segment's tables before reading them (CREATE TABLE IF NOT EXISTS creates
one in the segment even when public has a table of that name), and name
the segment in a DROP or ALTER that public could also answer.
Lower-case letters, digits and underscores; not public,
information_schema or a name beginning with pg_. A segment cannot be
combined with pool, nor with a connection string that sets its own
options startup parameter: pg sends those in place of the segment's.
OptionalpoolA pool the caller made (a pg Pool) for the adapter to run on, instead
of making one. The adapter runs on it from the start: no open() is
needed, and open() after close() takes it up again. The connection
settings above apply when a pool is made, so none of them, nor segment,
can be given with it.
OptionalownsWhether close() ends pool. False by default: the pool is its caller's,
and close() leaves it open. Pass true when the adapter is the pool's one
holder and closing the adapter is how the pool should end; close() then
ends it once, however often it is called.
OptionalonCalled with the error an idle connection of the pool reports (the server
ended it, the network dropped). pg's Pool raises such an error as an event
that, with no listener, ends the process. On a pool the adapter makes or
owns, the adapter listens even without onError and logs one warning per
error; on a pool of its caller's that it does not own, it listens only
when given onError, and takes its listener off again on close().
Configuration options for PostgreSQL adapter. Supports both connection strings and granular configuration.