Skip to main content

BindParam

Wraps a query parameter value together with an explicit PostgreSQL type OID, letting you override what DataTypeMap.determine() would otherwise infer from the JS value. Used in the params array of QueryOptions and ScriptExecuteOptions.

Constructor​

new BindParam(oid: OID, value: any)

ArgumentTypeDefaultDescription
oidOIDPostgreSQL data type OID for the value
valueanyThe parameter value
import { BindParam, Connection, DataTypeOIDs } from 'postgrejs';

const connection = new Connection('postgres://localhost');
await connection.connect();
await connection.query('select lo_unlink($1)', {
params: [new BindParam(DataTypeOIDs.oid, 12345)],
});

oid may be 0, which declares no type and leaves the server to resolve one from where the parameter appears — see OID 0: no declared type.

Properties​

KeyTypeReadonlyDescription
oidOIDfalsePostgreSQL data type OID for the value
valueanyfalseThe parameter value