Options
All
  • Public
  • Public/Protected
  • All
Menu

Allows to build complex sql queries in a fashion way and execute those queries.

Type parameters

  • Entity

Hierarchy

Index

Constructors

constructor

Properties

connection

connection: Connection

Connection on which QueryBuilder was created.

expressionMap

expressionMap: QueryExpressionMap

Contains all properties of the QueryBuilder that needs to be build a final query.

Protected Optional queryRunner

queryRunner: QueryRunner

Query runner used to execute query builder query.

Accessors

alias

  • get alias(): string

Methods

callListeners

  • callListeners(enabled: boolean): this
  • Indicates if listeners and subscribers must be called before and after query execution. Enabled by default.

    Parameters

    • enabled: boolean

    Returns this

clone

  • clone(): this
  • Clones query builder as it is. Note: it uses new query runner, if you want query builder that uses exactly same query runner, you can create query builder using its constructor, for example new SelectQueryBuilder(queryBuilder) where queryBuilder is cloned QueryBuilder.

    Returns this

Protected computeWhereParameter

Protected createFromAlias

  • createFromAlias(entityTarget: Function | string | function, aliasName?: undefined | string): Alias
  • Specifies FROM which entity's table select/update/delete will be executed. Also sets a main string alias of the selection data.

    Parameters

    • entityTarget: Function | string | function
    • Optional aliasName: undefined | string

    Returns Alias

createQueryBuilder

  • createQueryBuilder(): this

Protected createReturningExpression

  • createReturningExpression(): string

Protected createWhereExpression

  • createWhereExpression(): string

Protected createWhereExpressionString

  • createWhereExpressionString(): string

Protected createWhereIdsExpression

  • createWhereIdsExpression(ids: any | any[]): string

delete

disableEscaping

  • disableEscaping(): this

escape

  • escape(name: string): string
  • Escapes table name, column name or alias name using current database's escaping character.

    Parameters

    • name: string

    Returns string

execute

  • execute(): Promise<any>

Protected getMainTableName

  • getMainTableName(): string

getParameters

Abstract getQuery

  • getQuery(): string

getQueryAndParameters

  • getQueryAndParameters(): [string, any[]]

Protected getReturningColumns

getSql

  • getSql(): string
  • Gets generated sql that will be executed. Parameters in the query are escaped for the currently used driver.

    Returns string

Protected getTableName

  • getTableName(tablePath: string): string
  • Gets escaped table name with schema name if SqlServer driver used with custom schema name, otherwise returns escaped table name.

    Parameters

    • tablePath: string

    Returns string

hasRelation

  • hasRelation<T>(target: ObjectType<T> | string, relation: string): boolean
  • hasRelation<T>(target: ObjectType<T> | string, relation: string[]): boolean
  • Checks if given relation exists in the entity. Returns true if relation exists, false otherwise.

    todo: move this method to manager? or create a shortcut?

    Type parameters

    • T

    Parameters

    Returns boolean

  • Checks if given relations exist in the entity. Returns true if relation exists, false otherwise.

    todo: move this method to manager? or create a shortcut?

    Type parameters

    • T

    Parameters

    • target: ObjectType<T> | string
    • relation: string[]

    Returns boolean

insert

Protected obtainQueryRunner

printSql

  • printSql(): this

relation

Protected replacePropertyNames

  • replacePropertyNames(statement: string): string

select

setNativeParameters

setParameter

  • setParameter(key: string, value: any): this

setParameters

setQueryRunner

update

useTransaction

  • useTransaction(enabled: boolean): this

Generated using TypeDoc