Options
All
  • Public
  • Public/Protected
  • All
Menu

Runs queries on a single SQL Server 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.

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 queryResponsibilityChain

queryResponsibilityChain: Promise<any>[] = []

Last executed query in a transaction. This is needed because in transaction mode mssql cannot execute parallel queries, that's why we store last executed query promise to wait it when we execute next query.

see

https://github.com/patriksimek/node-mssql/issues/491

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

  • buildCreateColumnSql(table: Table, column: TableColumn, skipIdentity: boolean, createDefault: boolean): string

Protected buildForeignKeyName

  • buildForeignKeyName(fkName: string, schemaName: string | undefined, dbName: string | undefined): string
  • Concat database name and schema name to the foreign key name. Needs because FK name is relevant to the schema and database.

    Parameters

    • fkName: string
    • schemaName: string | undefined
    • dbName: string | undefined

    Returns string

changeColumn

changeColumns

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

clearDatabase

  • clearDatabase(database?: undefined | string): Promise<void>

clearSqlMemory

  • clearSqlMemory(): void

clearTable

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

commitTransaction

  • commitTransaction(): Promise<void>

connect

  • connect(): Promise<void>

convertIsolationLevel

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>

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(schemaPath: 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>

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): Promise<void>
  • Drops table schema. If database name also specified (e.g. 'dbName.schemaName') schema will be dropped in specified database.

    Parameters

    • schemaPath: string
    • Optional ifExist: undefined | true | false

    Returns Promise<void>

dropTable

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

    Parameters

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

    Returns Promise<void>

Protected dropTableSql

  • dropTableSql(tableOrName: Table | string, ifExist?: undefined | true | false): 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(tableOrName: 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 getCachedTable

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

Protected getCurrentDatabase

  • getCurrentDatabase(): Promise<string>

Protected getCurrentSchema

  • getCurrentSchema(): Promise<string>

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>

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 mssqlParameterToNativeParameter

Protected parseTableName

  • parseTableName(target: Table | string): object

query

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

release

  • release(): Promise<void>

Protected removeParenthesisFromDefault

  • removeParenthesisFromDefault(defaultValue: any): any
  • Removes parenthesis around default value. Sql server returns default value with parenthesis around, e.g. ('My text') - for string ((1)) - for number (newsequentialId()) - for function

    Parameters

    • defaultValue: any

    Returns any

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