interface PostgresStoreOpts {
    autocreateSchemaTable?: boolean;
    backoff?: boolean | ((attemptNum) => number);
    connect_timeout?: number;
    connection?: Partial<ConnectionParameters>;
    database?: string;
    db?: string;
    debug?: boolean | ((connection, query, parameters, paramTypes) => void);
    fetch_types?: boolean;
    host?: string;
    hostname?: string;
    idle_timeout?: number;
    keep_alive?: null | number;
    max?: number;
    max_lifetime?: null | number;
    no_prepare?: boolean;
    onclose?: ((connId) => void);
    onnotice?: ((notice) => void);
    onparameter?: ((key, value) => void);
    pass?: string | (() => string | Promise<string>);
    password?: string | (() => string | Promise<string>);
    path?: string;
    port?: number;
    prepare?: boolean;
    publications?: string;
    ssl?: boolean | object | "allow" | "require" | "prefer" | "verify-full";
    target_session_attrs?: "read-write" | "read-only" | "primary" | "standby" | "prefer-standby";
    timeout?: number;
    transform?: {
        column?: {
            from?: ((column) => string);
            to?: ((column) => string);
        } | ((column) => string);
        row?: {
            from?: ((row) => any);
        } | ((row) => any);
        undefined?: any;
        value?: {
            from?: ((value, column) => any);
        } | ((value) => any);
    };
    types?: Record<string, PostgresType<unknown>>;
    url?: string;
    user?: string;
    username?: string;
}

Hierarchy

  • Options<Record<string, PostgresType<unknown>>>
    • PostgresStoreOpts

Properties

autocreateSchemaTable?: boolean

Should the schema table be automatically created (the v0 schema effectively). Defaults to true.

backoff?: boolean | ((attemptNum) => number)

Type declaration

    • (attemptNum): number
    • Parameters

      • attemptNum: number

      Returns number

connect_timeout?: number

Connect timeout in seconds

Default

process.env['PGCONNECT_TIMEOUT']
connection?: Partial<ConnectionParameters>

Connection parameters

database?: string

Name of database to connect to

Default

process.env['PGDATABASE'] || options.user
db?: string

Name of database to connect to (an alias for database)

debug?: boolean | ((connection, query, parameters, paramTypes) => void)

Is called with (connection; query; parameters)

Type declaration

    • (connection, query, parameters, paramTypes): void
    • Parameters

      • connection: number
      • query: string
      • parameters: any[]
      • paramTypes: any[]

      Returns void

fetch_types?: boolean

Automatically fetches types on connect

Default

true
host?: string

Inherit Doc

hostname?: string

Postgres ip address or domain name (an alias for host)

idle_timeout?: number

Idle connection timeout in seconds

Default

process.env['PGIDLE_TIMEOUT']
keep_alive?: null | number
max?: number

Max number of connections

Default

10
max_lifetime?: null | number
no_prepare?: boolean

Disable prepared mode

Deprecated

use "prepare" option instead

onclose?: ((connId) => void)

Type declaration

    • (connId): void
    • Parameters

      • connId: number

      Returns void

onnotice?: ((notice) => void)

Called when a notice is received

Type declaration

    • (notice): void
    • Called when a notice is received

      Parameters

      • notice: Notice

      Returns void

      Default

      console.log
      

Default

console.log
onparameter?: ((key, value) => void)

(key; value) when a server param change

Type declaration

    • (key, value): void
    • (key; value) when a server param change

      Parameters

      • key: string
      • value: any

      Returns void

pass?: string | (() => string | Promise<string>)

Password of database user (an alias for password)

Type declaration

    • (): string | Promise<string>
    • Returns string | Promise<string>

password?: string | (() => string | Promise<string>)

Password of database user

Type declaration

    • (): string | Promise<string>
    • Returns string | Promise<string>

Default

process.env['PGPASSWORD']
path?: string

Inherit Doc

port?: number

Inherit Doc

prepare?: boolean

Enables prepare mode.

Default

true
publications?: string

Publications to subscribe to (only relevant when calling sql.subscribe())

Default

'alltables'
ssl?: boolean | object | "allow" | "require" | "prefer" | "verify-full"

How to deal with ssl (can be a tls.connect option object)

Default

false
target_session_attrs?: "read-write" | "read-only" | "primary" | "standby" | "prefer-standby"

Use 'read-write' with multiple hosts to ensure only connecting to primary

Default

process.env['PGTARGETSESSIONATTRS']
timeout?: number

Idle connection timeout in seconds

Deprecated

use "idle_timeout" option instead

transform?: {
    column?: {
        from?: ((column) => string);
        to?: ((column) => string);
    } | ((column) => string);
    row?: {
        from?: ((row) => any);
    } | ((row) => any);
    undefined?: any;
    value?: {
        from?: ((value, column) => any);
    } | ((value) => any);
}

Transform hooks

Type declaration

  • Optional column?: {
        from?: ((column) => string);
        to?: ((column) => string);
    } | ((column) => string)

    Transforms incoming and outgoing column names

  • Optional row?: {
        from?: ((row) => any);
    } | ((row) => any)

    Transforms entire rows

  • Optional undefined?: any

    Transforms outcoming undefined values

  • Optional value?: {
        from?: ((value, column) => any);
    } | ((value) => any)

    Transforms incoming and outgoing row values

types?: Record<string, PostgresType<unknown>>

Array of custom types; see more in the README

url?: string

URL to reach the database on.

user?: string

Username of database user

Default

process.env['PGUSERNAME'] || process.env['PGUSER'] || require('os').userInfo().username
username?: string

Username of database user (an alias for user)

Generated using TypeDoc