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

    类 InsertQueryBuilder<Entity>

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

    类型参数

    层级 (查看层级一览)

    索引

    构造函数

    属性

    "@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

    • Creates a columns string where values must be inserted to for INSERT INTO expression.

      返回 string

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

    • Creates INSERT express used to perform insert query.

      返回 string

    • 参数

      • 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

    • Creates list of values needs to be inserted in the VALUES expression.

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

    • 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<InsertResult>

    • 参数

      • subQuery: any

      返回 [string, any[]]

    • Gets list of columns where values must be inserted to.

      返回 ColumnMetadata[]

    • 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

    • Gets array of values need to be inserted into the target table.

      返回 ObjectLiteral[]

    • 参数

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

    • Specifies INTO which entity's table insertion will be executed.

      类型参数

      参数

      返回 InsertQueryBuilder<T>

    • Checks if column is an auto-generated primary key, but the current insertion specifies a value for it.

      参数

      • column: ColumnMetadata

      返回 boolean

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

      返回 QueryRunner

    • Adds additional ON CONFLICT statement supported in postgres and cockroach.

      参数

      • statement: string

      返回 this

      Use orIgnore or orUpdate

    • Adds additional ignore statement supported in databases.

      参数

      • 可选statement: string | boolean

      返回 this

    • 参数

      • 可选statement: {
            columns?: string[];
            conflict_target?: string | string[];
            overwrite?: string[];
        }

      返回 this

      .orUpdate({ columns: [ "is_updated" ] }).setParameter("is_updated", value)

      is now .orUpdate(["is_updated"])

      .orUpdate({ conflict_target: ['date'], overwrite: ['title'] })

      is now .orUpdate(['title'], ['date'])

    • 参数

      • overwrite: string[]
      • 可选conflictTarget: string | string[]
      • 可选orUpdateOptions: InsertOrUpdateOptions

      返回 this

      .orUpdate({ columns: [ "is_updated" ] }).setParameter("is_updated", value)

      is now .orUpdate(["is_updated"])

      .orUpdate({ conflict_target: ['date'], overwrite: ['title'] })

      is now .orUpdate(['title'], ['date'])

    • Optional returning/output clause. This will return given column values.

      参数

      • columns: string[]

      返回 this

    • Optional returning/output clause. Returning is a SQL string containing returning statement.

      参数

      • output: string

      返回 this

    • Optional returning/output clause.

      参数

      • output: string | string[]

      返回 this

    • 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>

    • Optional returning/output clause. This will return given column values.

      参数

      • columns: string[]

      返回 this

    • Optional returning/output clause. Returning is a SQL string containing returning statement.

      参数

      • returning: string

      返回 this

    • Optional returning/output clause.

      参数

      • returning: string | string[]

      返回 this

    • 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>

    • Indicates if entity must be updated after insertion operations. This may produce extra query or use RETURNING / OUTPUT statement (depend on database). Enabled by default.

      参数

      • enabled: boolean

      返回 this

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

      参数

      • enabled: boolean

      返回 this

    • Values needs to be inserted into table.

      参数

      返回 this

    • 参数

      • name: string
      • factory: any

      返回 void