Options
All
  • Public
  • Public/Protected
  • All
Menu

Allows to work with entity relations and perform specific operations with those relations.

todo: add transactions everywhere

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

add

  • add(value: any | any[]): Promise<void>
  • Adds (binds) given value to entity relation. Value can be entity, entity id or entity id map (if entity has composite ids). Value also can be array of entities, array of entity ids or array of entity id maps (if entity has composite ids). Works only for many-to-many and one-to-many relations. For many-to-one and one-to-one use #set method instead.

    Parameters

    • value: any | any[]

    Returns Promise<void>

addAndRemove

  • addAndRemove(added: any | any[], removed: any | any[]): Promise<void>
  • Adds (binds) and removes (unbinds) given values to/from entity relation. Value can be entity, entity id or entity id map (if entity has composite ids). Value also can be array of entities, array of entity ids or array of entity id maps (if entity has composite ids). Works only for many-to-many and one-to-many relations. For many-to-one and one-to-one use #set method instead.

    Parameters

    • added: any | any[]
    • removed: any | any[]

    Returns Promise<void>

callListeners

  • callListeners(enabled: boolean): 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

execute

  • execute(): Promise<any>

Protected getMainTableName

  • getMainTableName(): string

getParameters

getQuery

  • getQuery(): string

getQueryAndParameters

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

Protected getReturningColumns

getSql

  • getSql(): string

Protected getTableName

  • getTableName(tablePath: string): 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

loadMany

  • loadMany<T>(): Promise<T[]>
  • Loads many entities (relational) from the relation. You can also provide ids of relational entities to filter by.

    Type parameters

    • T

    Returns Promise<T[]>

loadOne

  • loadOne<T>(): Promise<T | undefined>
  • Loads a single entity (relational) from the relation. You can also provide id of relational entity to filter by.

    Type parameters

    • T

    Returns Promise<T | undefined>

Protected obtainQueryRunner

of

  • of(entity: any | any[]): this

printSql

  • printSql(): this

relation

remove

  • remove(value: any | any[]): Promise<void>
  • Removes (unbinds) given value from entity relation. Value can be entity, entity id or entity id map (if entity has composite ids). Value also can be array of entities, array of entity ids or array of entity id maps (if entity has composite ids). Works only for many-to-many and one-to-many relations. For many-to-one and one-to-one use #set method instead.

    Parameters

    • value: any | any[]

    Returns Promise<void>

Protected replacePropertyNames

  • replacePropertyNames(statement: string): string

select

set

  • set(value: any): Promise<void>
  • Sets entity relation's value. Value can be entity, entity id or entity id map (if entity has composite ids). Works only for many-to-one and one-to-one relations. For many-to-many and one-to-many relations use #add and #remove methods instead.

    Parameters

    • value: any

    Returns Promise<void>

setNativeParameters

setParameter

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

setParameters

setQueryRunner

update

useTransaction

  • useTransaction(enabled: boolean): this

Generated using TypeDoc