Options
All
  • Public
  • Public/Protected
  • All
Menu

Runs queries on a single postgres database connection.

Hierarchy

Implements

Index

Constructors

Properties

Methods

Constructors

constructor

Properties

broadcaster

broadcaster: Broadcaster

Broadcaster used on this query runner to broadcast entity events.

connection

connection: Connection

Connection used by this query runner.

data

data: object

Stores temporarily user data. Useful for sharing data with subscribers.

Type declaration

Protected databaseConnection

databaseConnection: any

Real database connection from a connection pool used to perform queries.

Protected databaseConnectionPromise

databaseConnectionPromise: Promise<any>

Promise used to obtain a database connection for a first time.

driver

Database driver used by connection.

isReleased

isReleased: boolean = false

Indicates if connection for this query runner is released. Once its released, query runner cannot run queries anymore.

isTransactionActive

isTransactionActive: boolean = false

Indicates if transaction is in progress.

loadedTables

loadedTables: Table[] = []

All synchronized tables in the database.

manager

manager: EntityManager

Entity manager working only with current query runner.

Protected mode

mode: "master" | "slave"

Mode in which query runner executes. Used for replication. If replication is not setup its value is ignored.

Protected releaseCallback

releaseCallback: Function

Special callback provided by a driver used to release a created connection.

Protected sqlInMemory

sqlInMemory: SqlInMemory = new SqlInMemory()

Sql-s stored if "sql in memory" mode is enabled.

Protected sqlMemoryMode

sqlMemoryMode: boolean = false

Indicates if special query runner mode in which sql queries won't be executed is enabled.

Methods

addColumn

addColumns

  • addColumns(tableOrName: Table | string, columns: TableColumn[]): Promise<void>

Protected buildCreateColumnSql

Protected buildEnumName

  • buildEnumName(table: Table, columnOrName: TableColumn | string, withSchema?: boolean, disableEscape?: undefined | true | false, toOld?: undefined | true | false): string
  • Builds ENUM type name from given table and column.

    Parameters

    • table: Table
    • columnOrName: TableColumn | string
    • Default value withSchema: boolean = true
    • Optional disableEscape: undefined | true | false
    • Optional toOld: undefined | true | false

    Returns string

Protected buildSequenceName

  • buildSequenceName(table: Table, columnOrName: TableColumn | string, currentSchema?: undefined | string, disableEscape?: undefined | true, skipSchema?: undefined | true | false): string
  • Builds sequence name from given table and column.

    Parameters

    • table: Table
    • columnOrName: TableColumn | string
    • Optional currentSchema: undefined | string
    • Optional disableEscape: undefined | true
    • Optional skipSchema: undefined | true | false

    Returns string

changeColumn

changeColumns

  • changeColumns(tableOrName: Table | string, changedColumns: object[]): Promise<void>

clearDatabase

  • clearDatabase(): Promise<void>

clearSqlMemory

  • clearSqlMemory(): void

clearTable

  • clearTable(tableName: string): Promise<void>

commitTransaction

  • commitTransaction(): Promise<void>

connect

  • connect(): Promise<any>

createCheckConstraint

  • createCheckConstraint(tableOrName: Table | string, checkConstraint: TableCheck): Promise<void>

Protected createCheckConstraintSql

  • createCheckConstraintSql(table: Table, checkConstraint: TableCheck): string

createCheckConstraints

  • createCheckConstraints(tableOrName: Table | string, checkConstraints: TableCheck[]): Promise<void>

createDatabase

  • createDatabase(database: string, ifNotExist?: undefined | true | false): Promise<void>

Protected createEnumTypeSql

  • createEnumTypeSql(table: Table, column: TableColumn, enumName?: undefined | string): string

createForeignKey

Protected createForeignKeySql

createForeignKeys

createIndex

  • createIndex(tableOrName: Table | string, index: TableIndex): Promise<void>

Protected createIndexSql

createIndices

  • createIndices(tableOrName: Table | string, indices: TableIndex[]): Promise<void>

createPrimaryKey

  • createPrimaryKey(tableOrName: Table | string, columnNames: string[]): Promise<void>

Protected createPrimaryKeySql

  • createPrimaryKeySql(table: Table, columnNames: string[]): string

createSchema

  • createSchema(schema: string, ifNotExist?: undefined | true | false): Promise<void>

createTable

  • createTable(table: Table, ifNotExist?: boolean, createForeignKeys?: boolean, createIndices?: boolean): Promise<void>
  • Creates a new table.

    Parameters

    • table: Table
    • Default value ifNotExist: boolean = false
    • Default value createForeignKeys: boolean = true
    • Default value createIndices: boolean = true

    Returns Promise<void>

Protected createTableSql

  • createTableSql(table: Table, createForeignKeys?: undefined | true | false): string

createUniqueConstraint

  • createUniqueConstraint(tableOrName: Table | string, uniqueConstraint: TableUnique): Promise<void>

Protected createUniqueConstraintSql

  • createUniqueConstraintSql(table: Table, uniqueConstraint: TableUnique): string

createUniqueConstraints

  • createUniqueConstraints(tableOrName: Table | string, uniqueConstraints: TableUnique[]): Promise<void>

disableSqlMemory

  • disableSqlMemory(): void

dropCheckConstraint

  • dropCheckConstraint(tableOrName: Table | string, checkOrName: TableCheck | string): Promise<void>

Protected dropCheckConstraintSql

  • dropCheckConstraintSql(table: Table, checkOrName: TableCheck | string): string

dropCheckConstraints

  • dropCheckConstraints(tableOrName: Table | string, checkConstraints: TableCheck[]): Promise<void>

dropColumn

  • dropColumn(tableOrName: Table | string, columnOrName: TableColumn | string): Promise<void>

dropColumns

  • dropColumns(tableOrName: Table | string, columns: TableColumn[]): Promise<void>

dropDatabase

  • dropDatabase(database: string, ifExist?: undefined | true | false): Promise<void>

Protected dropEnumTypeSql

  • dropEnumTypeSql(table: Table, column: TableColumn, enumName?: undefined | string): string

Protected dropEnumTypes

  • dropEnumTypes(schemaNames: string): Promise<void>

dropForeignKey

  • dropForeignKey(tableOrName: Table | string, foreignKeyOrName: TableForeignKey | string): Promise<void>

Protected dropForeignKeySql

dropForeignKeys

dropIndex

  • dropIndex(tableOrName: Table | string, indexOrName: TableIndex | string): Promise<void>

Protected dropIndexSql

dropIndices

  • dropIndices(tableOrName: Table | string, indices: TableIndex[]): Promise<void>

dropPrimaryKey

  • dropPrimaryKey(tableOrName: Table | string): Promise<void>

Protected dropPrimaryKeySql

  • dropPrimaryKeySql(table: Table): string

dropSchema

  • dropSchema(schemaPath: string, ifExist?: undefined | true | false, isCascade?: undefined | true | false): Promise<void>

dropTable

  • dropTable(target: Table | string, ifExist?: undefined | true | false, dropForeignKeys?: boolean, dropIndices?: boolean): Promise<void>
  • Drops the table.

    Parameters

    • target: Table | string
    • Optional ifExist: undefined | true | false
    • Default value dropForeignKeys: boolean = true
    • Default value dropIndices: boolean = true

    Returns Promise<void>

Protected dropTableSql

  • dropTableSql(tableOrPath: Table | string): string

dropUniqueConstraint

  • dropUniqueConstraint(tableOrName: Table | string, uniqueOrName: TableUnique | string): Promise<void>

Protected dropUniqueConstraintSql

  • dropUniqueConstraintSql(table: Table, uniqueOrName: TableUnique | string): string

dropUniqueConstraints

  • dropUniqueConstraints(tableOrName: Table | string, uniqueConstraints: TableUnique[]): Promise<void>

enableSqlMemory

  • enableSqlMemory(): void

Protected escapeTableName

  • escapeTableName(target: Table | string, disableEscape?: undefined | true | false): string

executeMemoryDownSql

  • executeMemoryDownSql(): Promise<void>

executeMemoryUpSql

  • executeMemoryUpSql(): Promise<void>

Protected executeQueries

  • executeQueries(upQueries: string | string[], downQueries: string | string[]): Promise<void>

Protected extractSchema

  • extractSchema(target: Table | string): string | undefined

Protected getCachedTable

  • getCachedTable(tableName: string): Promise<Table>

getDatabases

  • getDatabases(): Promise<string[]>

getMemorySql

getSchemas

  • getSchemas(database?: undefined | string): Promise<string[]>

getTable

  • getTable(tablePath: string): Promise<Table | undefined>

getTables

  • getTables(tableNames: string[]): Promise<Table[]>

hasColumn

  • hasColumn(tableOrName: Table | string, columnName: string): Promise<boolean>

hasDatabase

  • hasDatabase(database: string): Promise<boolean>

Protected hasEnumType

hasSchema

  • hasSchema(schema: string): Promise<boolean>

hasTable

  • hasTable(tableOrName: Table | string): Promise<boolean>

Protected isColumnChanged

  • isColumnChanged(oldColumn: TableColumn, newColumn: TableColumn, checkDefault?: undefined | true | false, checkComment?: undefined | true | false): boolean

Protected isDefaultColumnLength

  • isDefaultColumnLength(table: Table, column: TableColumn, length: string): boolean

Protected isDefaultColumnPrecision

  • isDefaultColumnPrecision(table: Table, column: TableColumn, precision: number): boolean

Protected isDefaultColumnScale

  • isDefaultColumnScale(table: Table, column: TableColumn, scale: number): boolean

Protected isDefaultColumnWidth

  • isDefaultColumnWidth(table: Table, column: TableColumn, width: number): boolean

Protected loadTables

  • loadTables(tableNames: string[]): Promise<Table[]>

Protected parseTableName

  • parseTableName(target: Table | string): object

query

  • query(query: string, parameters?: any[]): Promise<any>

release

  • release(): Promise<void>

renameColumn

  • renameColumn(tableOrName: Table | string, oldTableColumnOrName: TableColumn | string, newTableColumnOrName: TableColumn | string): Promise<void>

renameTable

  • renameTable(oldTableOrName: Table | string, newTableName: string): Promise<void>

Protected replaceCachedTable

  • replaceCachedTable(table: Table, changedTable: Table): void

rollbackTransaction

  • rollbackTransaction(): Promise<void>

startTransaction

stream

  • stream(query: string, parameters?: any[], onEnd?: Function, onError?: Function): Promise<ReadStream>

updatePrimaryKeys

  • updatePrimaryKeys(tableOrName: Table | string, columns: TableColumn[]): Promise<void>

Generated using TypeDoc