Built and signed on GitHub ActionsBuilt and signed on GitHub Actions
Lightweight PostgreSQL driver for Deno
Classes
Clients allow you to communicate with your PostgreSQL database and execute SQL statements asynchronously
A connection error
Connection pools are a powerful resource to execute parallel queries and save up time in connection initialization. It is highly recommended that all applications that require concurrent access use a pool to communicate with their PostgreSQL database
- available(): number
The number of open connections available for use
- connect(): Promise<PoolClient>
This will return a new client from the available connections in the pool
- end(): Promise<void>
This will close all open connections and set a terminated status in the pool
- initialized(): Promise<number>
This will return the number of initialized clients in the pool
- size(): number
The number of total connections open in the pool
A client used specifically by a connection pool
- release(): void
Releases the client back to the pool
A Postgres database error
This class is used to handle the result of a query that returns an array
An abstract class used to define common database client properties and methods
- closeConnection(): Promise<void>
Close the connection to the database
- connect(): Promise<void>
Every client must initialize their connection previously to the execution of any statement
- connected(): boolean
Indicates if the client is currently connected to the database
- createTransaction(): Transactionname: string,options?: TransactionOptions
Transactions are a powerful feature that guarantees safe operations by allowing you to control the outcome of a series of statements and undo, reset, and step back said operations to your liking
- end(): Promise<void>
Closing your PostgreSQL connection will delete all non-persistent data that may have been created in the course of the session and will require you to reconnect in order to execute further queries
- queryArray<T extends Array<unknown>>(): Promise<QueryArrayResult<T>>query: string,args?: QueryArguments
Execute queries and retrieve the data as array entries. It supports a generic in order to type the entries retrieved by the query
- queryObject<T>(): Promise<QueryObjectResult<T>>query: string,args?: QueryArguments
Executed queries and retrieve the data as object entries. It supports a generic in order to type the entries retrieved by the query
- resetSessionMetadata(): void
Resets the transaction session metadata
- session(): Session
The current session metadata
This class is used to handle the result of a query that returns an object
This class is used to handle the result of a query
- command: CommandType
Type of query executed for this result
- handleCommandComplete(commandTag: string): void
Handles the command complete message
- insertRow(_row: Uint8Array[]): void
Add a row to the result based on metadata provided by
rowDescriptionThis implementation depends on row description not being modified after initialization - loadColumnDescriptions(description: RowDescription): void
This function is required to parse each column of the results
- rowCount: number
The amount of rows affected by the query
- rowDescription(): RowDescription | undefined
The row description of the result
- warnings: Notice[]
The warnings of the result
Class to describe a row
A savepoint is a point in a transaction that you can roll back to
A transaction class
- begin(): Promise<void>
The begin method will officially begin the transaction, and it must be called before any query or transaction operation is executed in order to lock the session
- commit(options?: { chain?: boolean; }): Promise<void>
The commit method will make permanent all changes made to the database in the current transaction and end the current transaction
- getSavepoint(name: string): Savepoint | undefined
This method will search for the provided savepoint name and return a reference to the requested savepoint, otherwise it will return undefined
- getSavepoints(): string[]
This method will list you all of the active savepoints in this transaction
- getSnapshot(): Promise<string>
This method returns the snapshot id of the on going transaction, allowing you to share the snapshot state between two transactions
- isolation_level(): IsolationLevel
Get the isolation level of the transaction
- queryArray<T extends Array<unknown>>(): Promise<QueryArrayResult<T>>query: string,args?: QueryArguments
This method allows executed queries to be retrieved as array entries. It supports a generic interface in order to type the entries retrieved by the query
- queryObject<T>(): Promise<QueryObjectResult<T>>query: string,args?: QueryArguments
Executed queries and retrieve the data as object entries. It supports a generic in order to type the entries retrieved by the query
- rollback(): Promise<void>
Rollbacks are a mechanism to undo transaction operations without compromising the data that was modified during the transaction.
- savepoint(name: string): Promise<Savepoint>
This method will generate a savepoint, which will allow you to reset transaction states to a previous point of time
- savepoints(): Savepoint[]
Get all the savepoints of the transaction
A transaction error
Enums
Type of a query result
Interfaces
Additional granular database connection options
- attempts: number
By default, any client will only attempt to stablish connection with your database once. Setting this parameter will cause the client to attempt reconnection as many times as requested before erroring
- interval: number | ((previous_interval: number) => number)
The time to wait before attempting each reconnection (in milliseconds)
The notice interface defining the fields of a notice message
- code: string
The notice code
- column: string
The column name
- constraint: string
The constraint name
- dataType: string
The data type name
- detail: string
The additional notice detail
- file: string
The file name
- hint: string
The notice hint descrip=bing possible ways to fix this notice
- internalPosition: string
The internal position of code that triggered the notice
- internalQuery: string
The internal query that triggered the notice
- line: string
The line number
- message: string
The notice message
- position: string
The position of code that triggered the notice
- routine: string
The routine name
- schema: string
The database schema
- severity: string
The notice severity level
- table: string
The table name
- where: string
The where metadata
Options to control the behavior of a Query instance
- camelCase: boolean
Enabling camel case will transform any snake case field names coming from the database into camel case ones
- fields: string[]
This parameter supersedes query column names coming from the databases in the order they were provided. Fields must be unique and be in the range of (a-zA-Z0-9_), otherwise the query will throw before execution. A field can not start with a number, just like JavaScript variables
Types of options
The Session representing the current state of the connection
- current_transaction: string | null
This is the code for the transaction currently locking the connection. If there is no transaction ongoing, the transaction code will be null
- pid: number | undefined
This is the process id of the current session as assigned by the database on connection. This id will undefined when there is no connection stablished
- tls: boolean | undefined
Indicates if the connection is being carried over TLS. It will be undefined when there is no connection stablished
- transport: "tcp" | "socket" | undefined
This indicates the protocol used to connect to the database
The Transport Layer Security (TLS) protocol options to be used by the database connection
- caCertificates: string[]
A list of root certificates that will be used in addition to the default root certificates to verify the server's certificate.
- enabled: boolean
If TLS support is enabled or not. If the server requires TLS, the connection will fail.
- enforce: boolean
Forces the connection to run over TLS If the server doesn't support TLS, the connection will fail
Type Aliases
The Client database connection options
- applicationName: string
Name of the application connecing to the database
- connection: Partial<ConnectionOptions>
Additional connection options
- controls: ClientControls
Control the client behavior
- database: string
The database name
- host_type: "tcp" | "socket"
The type of host connection
- hostname: string
The name of the host
- options: string | Record<string, string>
Additional connection URI options https://www.postgresql.org/docs/current/libpq-connect.html#LIBPQ-PARAMKEYWORDS
- password: string
The database user password
- port: string | number
The database port used by the connection
- tls: Partial<TLSOptions>No documentation available
- user: string
The database user
| "DELETE"
| "UPDATE"
| "SELECT"
| "MOVE"
| "FETCH"
| "COPY"
| "CREATE"
Type of query to be executed
The connection string must match the following URI structure. All parameters but database and user are optional
A dictionary of functions used to decode (parse) column field values from string to a custom type. These functions will
take precedence over the DecodeStrategy. Each key in the dictionary is the column OID type number or Oid type name,
and the value is the decoder function.
The strategy to use when decoding results data
The isolation level of a transaction to control how we determine the data integrity between transactions
A Postgres Object identifiers (OIDs) type name.
A Postgres Object identifiers (OIDs) numeric value.
Types of arguments passed to a query
Type of the transaction options
- isolation_level: IsolationLevelNo documentation available
- read_only: booleanNo documentation available
- snapshot: stringNo documentation available
Variables
A map of OidType to OidValue.
- _abstime_0: numberNo documentation available
- _abstime_1: numberNo documentation available
- _aclitem_0: numberNo documentation available
- _aclitem_1: numberNo documentation available
- _any: numberNo documentation available
- _anyarray: numberNo documentation available
- _anyelement: numberNo documentation available
- _anyenum: numberNo documentation available
- _anynonarray: numberNo documentation available
- _anyrange: numberNo documentation available
- _bit_0: numberNo documentation available
- _bit_1: numberNo documentation available
- _cid_0: numberNo documentation available
- _cid_1: numberNo documentation available
- _cstring_0: numberNo documentation available
- _cstring_1: numberNo documentation available
- _daterange_0: numberNo documentation available
- _daterange_1: numberNo documentation available
- _event_trigger: numberNo documentation available
- _fdw_handler: numberNo documentation available
- _gtsvector_0: numberNo documentation available
- _gtsvector_1: numberNo documentation available
- _index_am_handler: numberNo documentation available
- _int2vector_0: numberNo documentation available
- _int2vector_1: numberNo documentation available
- _int4range_0: numberNo documentation available
- _int4range_1: numberNo documentation available
- _int8range_0: numberNo documentation available
- _int8range_1: numberNo documentation available
- _internal: numberNo documentation available
- _interval_0: numberNo documentation available
- _interval_1: numberNo documentation available
- _language_handler: numberNo documentation available
- _money_0: numberNo documentation available
- _money_1: numberNo documentation available
- _numrange_0: numberNo documentation available
- _numrange_1: numberNo documentation available
- _oidvector_0: numberNo documentation available
- _oidvector_1: numberNo documentation available
- _opaque: numberNo documentation available
- _pg_attribute: numberNo documentation available
- _pg_auth_members: numberNo documentation available
- _pg_authid: numberNo documentation available
- _pg_class: numberNo documentation available
- _pg_database: numberNo documentation available
- _pg_ddl_command: numberNo documentation available
- _pg_lsn_0: numberNo documentation available
- _pg_lsn_1: numberNo documentation available
- _pg_node_tree: numberNo documentation available
- _pg_proc: numberNo documentation available
- _pg_shseclabel: numberNo documentation available
- _pg_type: numberNo documentation available
- _record_0: numberNo documentation available
- _record_1: numberNo documentation available
- _refcursor_0: numberNo documentation available
- _refcursor_1: numberNo documentation available
- _reltime_0: numberNo documentation available
- _reltime_1: numberNo documentation available
- _smgr: numberNo documentation available
- _tinterval_0: numberNo documentation available
- _tinterval_1: numberNo documentation available
- _trigger: numberNo documentation available
- _tsm_handler: numberNo documentation available
- _tsquery_0: numberNo documentation available
- _tsquery_1: numberNo documentation available
- _tsrange_0: numberNo documentation available
- _tsrange_1: numberNo documentation available
- _tstzrange_0: numberNo documentation available
- _tstzrange_1: numberNo documentation available
- _tsvector_0: numberNo documentation available
- _tsvector_1: numberNo documentation available
- _txid_snapshot_0: numberNo documentation available
- _txid_snapshot_1: numberNo documentation available
- _unknown: numberNo documentation available
- _varbit_0: numberNo documentation available
- _varbit_1: numberNo documentation available
- _xml_0: numberNo documentation available
- _xml_1: numberNo documentation available
- bool: numberNo documentation available
- bool_array: numberNo documentation available
- box: numberNo documentation available
- box_array: numberNo documentation available
- bpchar: numberNo documentation available
- bpchar_array: numberNo documentation available
- byte_array: numberNo documentation available
- bytea: numberNo documentation available
- char: numberNo documentation available
- char_array: numberNo documentation available
- cidr: numberNo documentation available
- cidr_array: numberNo documentation available
- circle: numberNo documentation available
- circle_array: numberNo documentation available
- date: numberNo documentation available
- date_array: numberNo documentation available
- float4: numberNo documentation available
- float4_array: numberNo documentation available
- float8: numberNo documentation available
- float8_array: numberNo documentation available
- inet: numberNo documentation available
- inet_array: numberNo documentation available
- int2: numberNo documentation available
- int2_array: numberNo documentation available
- int4: numberNo documentation available
- int4_array: numberNo documentation available
- int8: numberNo documentation available
- int8_array: numberNo documentation available
- json: numberNo documentation available
- json_array: numberNo documentation available
- jsonb: numberNo documentation available
- jsonb_array: numberNo documentation available
- line: numberNo documentation available
- line_array: numberNo documentation available
- lseg: numberNo documentation available
- lseg_array: numberNo documentation available
- macaddr: numberNo documentation available
- macaddr_array: numberNo documentation available
- name: numberNo documentation available
- name_array: numberNo documentation available
- numeric: numberNo documentation available
- numeric_array: numberNo documentation available
- oid: numberNo documentation available
- oid_array: numberNo documentation available
- path: numberNo documentation available
- path_array: numberNo documentation available
- point: numberNo documentation available
- point_array: numberNo documentation available
- polygon: numberNo documentation available
- polygon_array: numberNo documentation available
- regclass: numberNo documentation available
- regclass_array: numberNo documentation available
- regconfig: numberNo documentation available
- regconfig_array: numberNo documentation available
- regdictionary: numberNo documentation available
- regdictionary_array: numberNo documentation available
- regnamespace: numberNo documentation available
- regnamespace_array: numberNo documentation available
- regoper: numberNo documentation available
- regoper_array: numberNo documentation available
- regoperator: numberNo documentation available
- regoperator_array: numberNo documentation available
- regproc: numberNo documentation available
- regproc_array: numberNo documentation available
- regprocedure: numberNo documentation available
- regprocedure_array: numberNo documentation available
- regrole: numberNo documentation available
- regrole_array: numberNo documentation available
- regtype: numberNo documentation available
- regtype_array: numberNo documentation available
- text: numberNo documentation available
- text_array: numberNo documentation available
- tid: numberNo documentation available
- tid_array: numberNo documentation available
- time: numberNo documentation available
- time_array: numberNo documentation available
- timestamp: numberNo documentation available
- timestamp_array: numberNo documentation available
- timestamptz: numberNo documentation available
- timestamptz_array: numberNo documentation available
- timetz: numberNo documentation available
- timetz_array: numberNo documentation available
- uuid: numberNo documentation available
- uuid_array: numberNo documentation available
- varchar: numberNo documentation available
- varchar_array: numberNo documentation available
- void: numberNo documentation available
- xid: numberNo documentation available
- xid_array: numberNo documentation available
A map of OidValue to OidType. Used to decode values and avoid search iteration.