API 参考
    正在准备搜索索引...

    类 QueryBuilder<Entity>抽象

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

    类型参数

    层级 (查看层级一览)

    索引

    构造函数

    • QueryBuilder can be initialized from given Connection and QueryRunner objects or from given other QueryBuilder.

      类型参数

      参数

      返回 QueryBuilder<Entity>

    • QueryBuilder can be initialized from given Connection and QueryRunner objects or from given other QueryBuilder.

      类型参数

      参数

      返回 QueryBuilder<Entity>

    属性

    "@instanceof": symbol
    connection: DataSource

    Connection on which QueryBuilder was created.

    expressionMap: QueryExpressionMap

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

    parentQueryBuilder: QueryBuilder<any>

    If QueryBuilder was created in a subquery mode then its parent QueryBuilder (who created subquery) will be stored here.

    queryRunner?: QueryRunner

    Query runner used to execute query builder query.

    访问器

    • get alias(): string

      Gets the main alias string used in this query builder.

      返回 string

    方法

    • Adds CTE to query

      参数

      • queryBuilder: string | QueryBuilder<any>
      • alias: string
      • 可选options: QueryBuilderCteOptions

      返回 this

    • Indicates if listeners and subscribers must be called before and after query execution. Enabled by default.

      参数

      • enabled: boolean

      返回 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.

      返回 this

    • Includes a Query comment in the query builder. This is helpful for debugging purposes, such as finding a specific query in the database server's logs, or for categorization using an APM product.

      参数

      • comment: string

      返回 this

    • 返回 string

    • 返回 string

    • Specifies FROM which entity's table select/update/delete will be executed. Also sets a main string alias of the selection data.

      参数

      返回 Alias

    • 参数

      • value: any

      返回 string

    • Creates a property paths for a given ObjectLiteral.

      参数

      返回 string[]

    • Creates a completely new query builder. Uses same query runner as current QueryBuilder.

      参数

      返回 this

    • Creates "RETURNING" / "OUTPUT" expression.

      参数

      • returningType: ReturningType

      返回 string

    • Time travel queries for CockroachDB

      返回 string

    • 参数

      • clauses: WhereClause[]

      返回 string

    • Computes given where argument - transforms to a where string all forms it can take.

      参数

      • condition: WhereClauseCondition
      • 可选alwaysWrap: boolean

      返回 string

    • Creates "WHERE" expression.

      返回 string

    • Creates DELETE query.

      返回 DeleteQueryBuilder<Entity>

    • Disables escaping.

      返回 this

    • Escapes table name, column name or alias name using current database's escaping character.

      参数

      • name: string

      返回 string

    • Executes sql generated by query builder and returns raw database results.

      返回 Promise<any>

    • 参数

      • subQuery: any

      返回 [string, any[]]

    • Gets name of the table where insert should be performed.

      返回 string

    • Gets all parameters.

      返回 ObjectLiteral

    • 参数

      返回 Generator<any[], void, unknown>

    • Gets generated SQL query without parameters being replaced.

      返回 string

    • Gets query to be executed with all parameters used in it.

      返回 [string, any[]]

    • If returning / output cause is set to array of column names, then this method will return all column metadatas of those column names.

      返回 ColumnMetadata[]

    • Gets generated sql that will be executed. Parameters in the query are escaped for the currently used driver.

      返回 string

    • Gets escaped table name with schema name if SqlServer driver used with custom schema name, otherwise returns escaped table name.

      参数

      • tablePath: string

      返回 string

    • 参数

      返回 WhereClauseCondition

    • Creates "WHERE" condition for an in-ids condition.

      参数

      • ids: any

      返回 ObjectLiteral | Brackets

    • 参数

      • aliasPath: string
      • parameterValue: any

      返回 WhereClauseCondition

    • 返回 boolean

    • Check the existence of a parameter for this query builder.

      参数

      • key: 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?

      类型参数

      • T

      参数

      返回 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?

      类型参数

      • T

      参数

      返回 boolean

    • Creates INSERT query.

      返回 InsertQueryBuilder<Entity>

    • Creates a query builder used to execute sql queries inside this query builder.

      返回 QueryRunner

    • Prints sql to stdout using console.log.

      返回 this

    • Sets entity's relation with which this query builder gonna work.

      参数

      • propertyPath: string

      返回 RelationQueryBuilder<Entity>

    • Sets entity's relation with which this query builder gonna work.

      类型参数

      参数

      返回 RelationQueryBuilder<T>

    • 参数

      • statement: string

      返回 string

      this way of replace property names is too slow. Instead, we'll replace property names at the end - once query is build.

    • Replaces all entity's propertyName to name in the given SQL string.

      参数

      • statement: string

      返回 string

    • 返回 SoftDeleteQueryBuilder<any>

    • Creates SELECT query. Replaces all previous selections if they exist.

      返回 SelectQueryBuilder<Entity>

    • Creates SELECT query and selects given data. Replaces all previous selections if they exist.

      参数

      • selection: string
      • 可选selectionAliasName: string

      返回 SelectQueryBuilder<Entity>

    • Creates SELECT query and selects given data. Replaces all previous selections if they exist.

      参数

      • selection: string[]

      返回 SelectQueryBuilder<Entity>

    • Adds native parameters from the given object.

      参数

      返回 this

      Use setParameters instead

    • Sets parameter name and its value.

      The key for this parameter may contain numbers, letters, underscores, or periods.

      参数

      • key: string
      • value: any

      返回 this

    • Adds all parameters from the given object.

      参数

      返回 this

    • Sets or overrides query builder's QueryRunner.

      参数

      返回 this

    • 返回 SoftDeleteQueryBuilder<any>

    • Creates UPDATE query and applies given update values.

      返回 UpdateQueryBuilder<Entity>

    • Creates UPDATE query and applies given update values.

      参数

      • updateSet: QueryDeepPartialEntity<Entity>

      返回 UpdateQueryBuilder<Entity>

    • Creates UPDATE query for the given entity and applies given update values.

      类型参数

      参数

      返回 UpdateQueryBuilder<Entity>

    • Creates UPDATE query for the given table name and applies given update values.

      参数

      返回 UpdateQueryBuilder<Entity>

    • If set to true the query will be wrapped into a transaction.

      参数

      • enabled: boolean

      返回 this

    • 参数

      • name: string
      • factory: any

      返回 void