Class PostgresInstance

Constructors

Properties

#authMethod: string = "password"
#hasPostgresStarted: boolean = false
#id: string
#isInitialize: boolean = false
#isRootUser: boolean
#process?: ChildProcess

Accessors

Methods

  • Create the data directory and have the user own it.

    Parameters

    • permissionIds: {
          gid: number;
          uid: number;
      }
      • gid: number
      • uid: number

    Returns Promise<void>

  • Create a file on disk that contains the password in plaintext.

    Returns Promise<string>

    password file path

  • Retrieve the uid and gid for a particular user

    Parameters

    • name: string = "postgres"

    Returns Promise<Record<string, never> | {
        gid: number;
        uid: number;
    }>

  • Initialize postgres database directory

    Parameters

    • initdbExe: string
    • passwordFile: string
    • permissionIds: {
          gid: number;
          uid: number;
      }
      • gid: number
      • uid: number

    Returns Promise<void>

  • Create a node postgres client using the existing postgres instance configuration.

    Parameters

    • database: string = "postgres"

      The database that the postgres client should connect to

    • host: string = "localhost"

      The host that should be pre-filled in the connection options

    Returns Client

    Client

  • Create a database with a given name on the postgres instance.

    Parameters

    • databaseName: string

    Returns Promise<void>

  • Drop a database with a given name on the postgres instance.

    Parameters

    • databaseName: string

    Returns Promise<void>

  • Determine if database with a given name on the postgres instance exist.

    Parameters

    • databaseName: string

    Returns Promise<boolean>

  • Make a query on the postgres instance.

    Type Parameters

    • T extends QueryResultRow = any

    Parameters

    • queryTextOrConfig: string
    • values: any[] = []
    • database: string = "postgres"

      The database that the postgres client should perform the query from

    • host: string = "localhost"

      The host that the postgres client should connect to

    Returns Promise<QueryResult<T>>

  • Start the Postgres instance. It is automatically shut down when the script exits.

    Returns Promise<void>

Generated using TypeDoc