Interface PostgresStoreOpts

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) => 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: number, query: string, parameters: any[], paramTypes: any[]) => void)

Is called with (connection; query; parameters)

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: number) => void)

Type declaration

    • (connId: number): void
    • Parameters

      • connId: number

      Returns void

onnotice?: ((notice: Notice) => void)

Type declaration

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

      Default

      console.log

      Parameters

      • notice: Notice

      Returns void

onparameter?: ((key: string, value: any) => void)

Type declaration

    • (key: string, value: any): 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)

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

Password of database user

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 | "require" | "allow" | "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?: ((column: string) => string) | {
        from?: ((column: string) => string);
        to?: ((column: string) => string);
    };
    row?: ((row: Row) => any) | {
        from?: ((row: Row) => any);
    };
    undefined?: any;
    value?: ((value: any) => any) | {
        from?: ((value: unknown, column: Column<string>) => any);
    };
}

Transform hooks

Type declaration

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

    Transforms incoming and outgoing column names

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

    Transforms entire rows

  • Optional undefined?: any

    Transforms outcoming undefined values

  • Optional value?: ((value: any) => any) | {
        from?: ((value: unknown, column: Column<string>) => 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