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

    类 SelectQueryBuilder<Entity>

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

    类型参数

    层级 (查看层级一览)

    实现

    索引

    构造函数

    属性

    访问器

    方法

    addCommonTableExpression addFrom addGroupBy addOrderBy addSelect andHaving andWhere andWhereExists andWhereInIds applyFindOptions buildEagerRelations buildEscapedEntityColumnSelects buildOrder buildRelations buildSelect buildWhere cache callListeners clone comment concatRelationMetadata createComment createCteExpression createFromAlias createGroupByExpression createHavingExpression createJoinExpression createLimitOffsetExpression createLockExpression createOrderByCombinedWithSelectExpression createOrderByExpression createParameter createPropertyPath createQueryBuilder createReturningExpression createSelectDistinctExpression createSelectExpression createTimeTravelQuery createWhereClausesExpression createWhereConditionExpression createWhereExpression delete disableEscaping distinct distinctOn escape execute executeCountQuery executeEntitiesAndRawResults executeExistsQuery findEntityColumnSelects from fromDummy getCount getExists getExistsCondition getMainTableName getMany getManyAndCount getOne getOneOrFail getParameters getPredicates getQuery getQueryAndParameters getRawAndEntities getRawMany getRawOne getReturningColumns getSql getTableName getWhereCondition getWhereInIdsCondition getWherePredicateCondition groupBy hasCommonTableExpressions hasParameter hasRelation having innerJoin innerJoinAndMapMany innerJoinAndMapOne innerJoinAndSelect insert join leftJoin leftJoinAndMapMany leftJoinAndMapOne leftJoinAndSelect limit loadAllRelationIds loadRawResults loadRelationCountAndMap loadRelationIdAndMap maxExecutionTime mergeExpressionMap normalizeNumber obtainQueryRunner offset orderBy orHaving orWhere orWhereExists orWhereInIds printSql relation replacePropertyNames replacePropertyNamesForTheWholeQuery restore select setFindOptions setLock setNativeParameters setOnLocked setOption setParameter setParameters setQueryRunner skip softDelete stream subQuery take timeTravelQuery update useIndex useTransaction where whereExists whereInIds withDeleted registerQueryBuilderClass

    构造函数

    属性

    "@instanceof": symbol
    conditions: string
    connection: DataSource

    Connection on which QueryBuilder was created.

    expressionMap: QueryExpressionMap

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

    findOptions: FindManyOptions
    joins: {
        alias: string;
        parentAlias: string;
        relationMetadata: RelationMetadata;
        select: boolean;
        selection: undefined | FindOptionsSelect<any>;
        type: "inner" | "left";
    }[]
    orderBys: {
        alias: string;
        direction: "ASC" | "DESC";
        nulls?: "NULLS FIRST" | "NULLS LAST";
    }[]
    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.

    relationMetadatas: RelationMetadata[]
    selects: string[]

    访问器

    • 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

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

      类型参数

      参数

      返回 SelectQueryBuilder<T>

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

      类型参数

      参数

      返回 SelectQueryBuilder<T>

    • Adds GROUP BY condition in the query builder.

      参数

      • groupBy: string

      返回 this

    • Adds ORDER BY condition in the query builder.

      参数

      • sort: string
      • 可选order: "ASC" | "DESC"
      • 可选nulls: "NULLS FIRST" | "NULLS LAST"

      返回 this

    • Adds new selection to the SELECT query.

      参数

      返回 this

    • Adds new selection to the SELECT query.

      参数

      • selection: string
      • 可选selectionAliasName: string

      返回 this

    • Adds new selection to the SELECT query.

      参数

      • selection: string[]

      返回 this

    • Adds new AND HAVING condition in the query builder. Additionally you can add parameters used in where expression.

      参数

      返回 this

    • Adds new AND WHERE condition in the query builder. Additionally you can add parameters used in where expression.

      参数

      返回 this

    • Adds a new AND where EXISTS clause

      参数

      返回 this

    • Adds new AND WHERE with conditions for the given ids.

      Ids are mixed. It means if you have single primary key you can pass a simple id values, for example [1, 2, 3]. If you have multiple primary keys you need to pass object with property names and values specified, for example [{ firstId: 1, secondId: 2 }, { firstId: 2, secondId: 3 }, ...]

      参数

      • ids: any

      返回 this

    • 返回 void

    • 参数

      返回 void

    • 参数

      返回 SelectQuery[]

    • 参数

      返回 void

    • 参数

      返回 void

    • 参数

      返回 void

    • 参数

      返回 string

    • Enables or disables query result caching.

      参数

      • enabled: boolean

      返回 this

    • Enables query result caching and sets in milliseconds in which cache will expire. If not set then global caching time will be used.

      参数

      • milliseconds: number

      返回 this

    • Enables query result caching and sets cache id and milliseconds in which cache will expire.

      参数

      • id: any
      • 可选milliseconds: number

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

    • 参数

      • relationMetadata: RelationMetadata

      返回 void

    • 返回 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 "GROUP BY" part of SQL query.

      返回 string

    • Creates "HAVING" part of SQL query.

      返回 string

    • Creates "JOIN" part of SQL query.

      返回 string

    • Creates "LIMIT" and "OFFSET" parts of SQL query.

      返回 string

    • Creates "LOCK" part of SQL query.

      返回 string

    • 参数

      • parentAlias: string

      返回 [string, OrderByCondition]

    • Creates "ORDER BY" part of SQL 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

    • Creates select | select distinct part of SQL query.

      返回 string

    • Creates "SELECT FROM" part of SQL query.

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

    • Disables escaping.

      返回 this

    • Sets whether the selection is DISTINCT.

      参数

      • 可选distinct: boolean

      返回 this

    • Sets the distinct on clause for Postgres.

      参数

      • distinctOn: string[]

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

    • 参数

      返回 Promise<number>

    • Executes sql generated by query builder and returns object with raw results and entities created from them.

      参数

      返回 Promise<{ entities: Entity[]; raw: any[] }>

    • 参数

      返回 Promise<boolean>

    • 参数

      返回 SelectQuery[]

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

      类型参数

      参数

      返回 SelectQueryBuilder<T>

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

      类型参数

      参数

      返回 SelectQueryBuilder<T>

    • 返回 SelectQueryBuilder<any>

    • Gets count - number of entities selected by sql generated by this query builder. Count excludes all limitations set by offset, limit, skip, and take.

      返回 Promise<number>

    • Gets exists Returns whether any rows exists matching current query.

      返回 Promise<boolean>

    • 参数

      • subQuery: any

      返回 [string, any[]]

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

      返回 string

    • Gets entities returned by execution of generated query builder sql.

      返回 Promise<Entity[]>

    • Executes built SQL query and returns entities and overall entities count (without limitation). This method is useful to build pagination.

      返回 Promise<[Entity[], number]>

    • Gets single entity returned by execution of generated query builder sql.

      返回 Promise<null | Entity>

    • Gets the first entity returned by execution of generated query builder sql or rejects the returned promise on error.

      返回 Promise<Entity>

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

    • Executes sql generated by query builder and returns object with raw results and entities created from them.

      类型参数

      • T = any

      返回 Promise<{ entities: Entity[]; raw: T[] }>

    • Gets all raw results returned by execution of generated query builder sql.

      类型参数

      • T = any

      返回 Promise<T[]>

    • Gets first raw result returned by execution of generated query builder sql.

      类型参数

      • T = any

      返回 Promise<undefined | T>

    • 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

    • Sets GROUP BY condition in the query builder. If you had previously GROUP BY expression defined, calling this function will override previously set GROUP BY conditions.

      返回 this

    • Sets GROUP BY condition in the query builder. If you had previously GROUP BY expression defined, calling this function will override previously set GROUP BY conditions.

      参数

      • groupBy: string

      返回 this

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

    • Sets HAVING condition in the query builder. If you had previously HAVING expression defined, calling this function will override previously set HAVING conditions. Additionally you can add parameters used in where expression.

      参数

      返回 this

    • INNER JOINs (without selection) given subquery. You also need to specify an alias of the joined data. Optionally, you can add condition and parameters used in condition.

      参数

      返回 this

    • INNER JOINs (without selection) entity's property. Given entity property should be a relation. You also need to specify an alias of the joined data. Optionally, you can add condition and parameters used in condition.

      参数

      • property: string
      • alias: string
      • 可选condition: string
      • 可选parameters: ObjectLiteral

      返回 this

    • INNER JOINs (without selection) given entity's table. You also need to specify an alias of the joined data. Optionally, you can add condition and parameters used in condition.

      参数

      • entity: string | Function
      • alias: string
      • 可选condition: string
      • 可选parameters: ObjectLiteral

      返回 this

    • INNER JOINs (without selection) given table. You also need to specify an alias of the joined data. Optionally, you can add condition and parameters used in condition.

      参数

      • tableName: string
      • alias: string
      • 可选condition: string
      • 可选parameters: ObjectLiteral

      返回 this

    • INNER JOINs given subquery, SELECTs the data returned by a join and MAPs all that data to some entity's property. This is extremely useful when you want to select some data and map it to some virtual property. It will assume that there are multiple rows of selecting data, and mapped result will be an array. Given entity property should be a relation. You also need to specify an alias of the joined data. Optionally, you can add condition and parameters used in condition.

      参数

      返回 this

    • INNER JOINs entity's property, SELECTs the data returned by a join and MAPs all that data to some entity's property. This is extremely useful when you want to select some data and map it to some virtual property. It will assume that there are multiple rows of selecting data, and mapped result will be an array. Given entity property should be a relation. You also need to specify an alias of the joined data. Optionally, you can add condition and parameters used in condition.

      参数

      • mapToProperty: string
      • property: string
      • alias: string
      • 可选condition: string
      • 可选parameters: ObjectLiteral

      返回 this

    • INNER JOINs entity's table, SELECTs the data returned by a join and MAPs all that data to some entity's property. This is extremely useful when you want to select some data and map it to some virtual property. It will assume that there are multiple rows of selecting data, and mapped result will be an array. You also need to specify an alias of the joined data. Optionally, you can add condition and parameters used in condition.

      参数

      • mapToProperty: string
      • entity: string | Function
      • alias: string
      • 可选condition: string
      • 可选parameters: ObjectLiteral

      返回 this

    • INNER JOINs table, SELECTs the data returned by a join and MAPs all that data to some entity's property. This is extremely useful when you want to select some data and map it to some virtual property. It will assume that there are multiple rows of selecting data, and mapped result will be an array. You also need to specify an alias of the joined data. Optionally, you can add condition and parameters used in condition.

      参数

      • mapToProperty: string
      • tableName: string
      • alias: string
      • 可选condition: string
      • 可选parameters: ObjectLiteral

      返回 this

    • INNER JOINs given subquery, SELECTs the data returned by a join and MAPs all that data to some entity's property. This is extremely useful when you want to select some data and map it to some virtual property. It will assume that there is a single row of selecting data, and mapped result will be a single selected value. Given entity property should be a relation. You also need to specify an alias of the joined data. Optionally, you can add condition and parameters used in condition.

      参数

      返回 this

    • INNER JOINs entity's property, SELECTs the data returned by a join and MAPs all that data to some entity's property. This is extremely useful when you want to select some data and map it to some virtual property. It will assume that there is a single row of selecting data, and mapped result will be a single selected value. Given entity property should be a relation. You also need to specify an alias of the joined data. Optionally, you can add condition and parameters used in condition.

      参数

      • mapToProperty: string
      • property: string
      • alias: string
      • 可选condition: string
      • 可选parameters: ObjectLiteral

      返回 this

    • INNER JOINs entity's table, SELECTs the data returned by a join and MAPs all that data to some entity's property. This is extremely useful when you want to select some data and map it to some virtual property. It will assume that there is a single row of selecting data, and mapped result will be a single selected value. You also need to specify an alias of the joined data. Optionally, you can add condition and parameters used in condition.

      参数

      • mapToProperty: string
      • entity: string | Function
      • alias: string
      • 可选condition: string
      • 可选parameters: ObjectLiteral

      返回 this

    • INNER JOINs table, SELECTs the data returned by a join and MAPs all that data to some entity's property. This is extremely useful when you want to select some data and map it to some virtual property. It will assume that there is a single row of selecting data, and mapped result will be a single selected value. You also need to specify an alias of the joined data. Optionally, you can add condition and parameters used in condition.

      参数

      • mapToProperty: string
      • tableName: string
      • alias: string
      • 可选condition: string
      • 可选parameters: ObjectLiteral

      返回 this

    • INNER JOINs given subquery and adds all selection properties to SELECT.. You also need to specify an alias of the joined data. Optionally, you can add condition and parameters used in condition.

      参数

      返回 this

    • INNER JOINs entity's property and adds all selection properties to SELECT. Given entity property should be a relation. You also need to specify an alias of the joined data. Optionally, you can add condition and parameters used in condition.

      参数

      • property: string
      • alias: string
      • 可选condition: string
      • 可选parameters: ObjectLiteral

      返回 this

    • INNER JOINs entity and adds all selection properties to SELECT. You also need to specify an alias of the joined data. Optionally, you can add condition and parameters used in condition.

      参数

      • entity: string | Function
      • alias: string
      • 可选condition: string
      • 可选parameters: ObjectLiteral

      返回 this

    • INNER JOINs table and adds all selection properties to SELECT. You also need to specify an alias of the joined data. Optionally, you can add condition and parameters used in condition.

      参数

      • tableName: string
      • alias: string
      • 可选condition: string
      • 可选parameters: ObjectLiteral

      返回 this

    • 参数

      • direction: "INNER" | "LEFT"
      • entityOrProperty: string | Function | ((qb: SelectQueryBuilder<any>) => SelectQueryBuilder<any>)
      • aliasName: string
      • 可选condition: string
      • 可选parameters: ObjectLiteral
      • 可选mapToProperty: string
      • 可选isMappingMany: boolean
      • 可选mapAsEntity: string | Function

      返回 void

    • LEFT JOINs (without selection) given subquery. You also need to specify an alias of the joined data. Optionally, you can add condition and parameters used in condition.

      参数

      返回 this

    • LEFT JOINs (without selection) entity's property. Given entity property should be a relation. You also need to specify an alias of the joined data. Optionally, you can add condition and parameters used in condition.

      参数

      • property: string
      • alias: string
      • 可选condition: string
      • 可选parameters: ObjectLiteral

      返回 this

    • LEFT JOINs (without selection) entity's table. You also need to specify an alias of the joined data. Optionally, you can add condition and parameters used in condition.

      参数

      • entity: string | Function
      • alias: string
      • 可选condition: string
      • 可选parameters: ObjectLiteral

      返回 this

    • LEFT JOINs (without selection) given table. You also need to specify an alias of the joined data. Optionally, you can add condition and parameters used in condition.

      参数

      • tableName: string
      • alias: string
      • 可选condition: string
      • 可选parameters: ObjectLiteral

      返回 this

    • LEFT JOINs given subquery, SELECTs the data returned by a join and MAPs all that data to some entity's property. This is extremely useful when you want to select some data and map it to some virtual property. It will assume that there are multiple rows of selecting data, and mapped result will be an array. Given entity property should be a relation. You also need to specify an alias of the joined data. Optionally, you can add condition and parameters used in condition.

      参数

      返回 this

    • LEFT JOINs entity's property, SELECTs the data returned by a join and MAPs all that data to some entity's property. This is extremely useful when you want to select some data and map it to some virtual property. It will assume that there are multiple rows of selecting data, and mapped result will be an array. Given entity property should be a relation. You also need to specify an alias of the joined data. Optionally, you can add condition and parameters used in condition.

      参数

      • mapToProperty: string
      • property: string
      • alias: string
      • 可选condition: string
      • 可选parameters: ObjectLiteral

      返回 this

    • LEFT JOINs entity's table, SELECTs the data returned by a join and MAPs all that data to some entity's property. This is extremely useful when you want to select some data and map it to some virtual property. It will assume that there are multiple rows of selecting data, and mapped result will be an array. You also need to specify an alias of the joined data. Optionally, you can add condition and parameters used in condition.

      参数

      • mapToProperty: string
      • entity: string | Function
      • alias: string
      • 可选condition: string
      • 可选parameters: ObjectLiteral

      返回 this

    • LEFT JOINs table, SELECTs the data returned by a join and MAPs all that data to some entity's property. This is extremely useful when you want to select some data and map it to some virtual property. It will assume that there are multiple rows of selecting data, and mapped result will be an array. You also need to specify an alias of the joined data. Optionally, you can add condition and parameters used in condition.

      参数

      • mapToProperty: string
      • tableName: string
      • alias: string
      • 可选condition: string
      • 可选parameters: ObjectLiteral

      返回 this

    • LEFT JOINs given subquery, SELECTs the data returned by a join and MAPs all that data to some entity's property. This is extremely useful when you want to select some data and map it to some virtual property. It will assume that there is a single row of selecting data, and mapped result will be a single selected value. Given entity property should be a relation. You also need to specify an alias of the joined data. Optionally, you can add condition and parameters used in condition.

      参数

      返回 this

    • LEFT JOINs entity's property, SELECTs the data returned by a join and MAPs all that data to some entity's property. This is extremely useful when you want to select some data and map it to some virtual property. It will assume that there is a single row of selecting data, and mapped result will be a single selected value. Given entity property should be a relation. You also need to specify an alias of the joined data. Optionally, you can add condition and parameters used in condition.

      参数

      • mapToProperty: string
      • property: string
      • alias: string
      • 可选condition: string
      • 可选parameters: ObjectLiteral

      返回 this

    • LEFT JOINs entity's table, SELECTs the data returned by a join and MAPs all that data to some entity's property. This is extremely useful when you want to select some data and map it to some virtual property. It will assume that there is a single row of selecting data, and mapped result will be a single selected value. You also need to specify an alias of the joined data. Optionally, you can add condition and parameters used in condition.

      参数

      • mapToProperty: string
      • entity: string | Function
      • alias: string
      • 可选condition: string
      • 可选parameters: ObjectLiteral

      返回 this

    • LEFT JOINs table, SELECTs the data returned by a join and MAPs all that data to some entity's property. This is extremely useful when you want to select some data and map it to some virtual property. It will assume that there is a single row of selecting data, and mapped result will be a single selected value. You also need to specify an alias of the joined data. Optionally, you can add condition and parameters used in condition.

      参数

      • mapToProperty: string
      • tableName: string
      • alias: string
      • 可选condition: string
      • 可选parameters: ObjectLiteral

      返回 this

    • LEFT JOINs given subquery and adds all selection properties to SELECT.. You also need to specify an alias of the joined data. Optionally, you can add condition and parameters used in condition.

      参数

      返回 this

    • LEFT JOINs entity's property and adds all selection properties to SELECT. Given entity property should be a relation. You also need to specify an alias of the joined data. Optionally, you can add condition and parameters used in condition.

      参数

      • property: string
      • alias: string
      • 可选condition: string
      • 可选parameters: ObjectLiteral

      返回 this

    • LEFT JOINs entity and adds all selection properties to SELECT. You also need to specify an alias of the joined data. Optionally, you can add condition and parameters used in condition.

      参数

      • entity: string | Function
      • alias: string
      • 可选condition: string
      • 可选parameters: ObjectLiteral

      返回 this

    • LEFT JOINs table and adds all selection properties to SELECT. You also need to specify an alias of the joined data. Optionally, you can add condition and parameters used in condition.

      参数

      • tableName: string
      • alias: string
      • 可选condition: string
      • 可选parameters: ObjectLiteral

      返回 this

    • Sets LIMIT - maximum number of rows to be selected. NOTE that it may not work as you expect if you are using joins. If you want to implement pagination, and you are having join in your query, then use the take method instead.

      参数

      • 可选limit: number

      返回 this

    • Loads all relation ids for all relations of the selected entity. All relation ids will be mapped to relation property themself. If array of strings is given then loads only relation ids of the given properties.

      参数

      • 可选options: { disableMixedMap?: boolean; relations?: string[] }

      返回 this

    • Loads raw results from the database.

      参数

      返回 Promise<any>

    • Counts number of entities of entity's relation and maps the value into some entity's property. Optionally, you can add condition and parameters used in condition.

      参数

      返回 this

    • LEFT JOINs relation id and maps it into some entity's property. Optionally, you can add condition and parameters used in condition.

      参数

      • mapToProperty: string
      • relationName: string
      • 可选options: { disableMixedMap?: boolean }

      返回 this

    • LEFT JOINs relation id and maps it into some entity's property. Optionally, you can add condition and parameters used in condition.

      参数

      返回 this

    • Set max execution time.

      参数

      • milliseconds: number

      返回 this

    • Merges into expression map given expression map properties.

      参数

      • expressionMap: Partial<QueryExpressionMap>

      返回 this

    • Normalizes a give number - converts to int if possible.

      参数

      • num: any

      返回 any

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

      返回 QueryRunner

    • Sets OFFSET - selection offset. NOTE that it may not work as you expect if you are using joins. If you want to implement pagination, and you are having join in your query, then use the skip method instead.

      参数

      • 可选offset: number

      返回 this

    • Sets ORDER BY condition in the query builder. If you had previously ORDER BY expression defined, calling this function will override previously set ORDER BY conditions.

      Calling order by without order set will remove all previously set order bys.

      返回 this

    • Sets ORDER BY condition in the query builder. If you had previously ORDER BY expression defined, calling this function will override previously set ORDER BY conditions.

      参数

      • sort: string
      • 可选order: "ASC" | "DESC"
      • 可选nulls: "NULLS FIRST" | "NULLS LAST"

      返回 this

    • Sets ORDER BY condition in the query builder. If you had previously ORDER BY expression defined, calling this function will override previously set ORDER BY conditions.

      参数

      返回 this

    • Adds new OR HAVING condition in the query builder. Additionally you can add parameters used in where expression.

      参数

      返回 this

    • Adds new OR WHERE condition in the query builder. Additionally you can add parameters used in where expression.

      参数

      返回 this

    • Adds a new OR where EXISTS clause

      参数

      返回 this

    • Adds new OR WHERE with conditions for the given ids.

      Ids are mixed. It means if you have single primary key you can pass a simple id values, for example [1, 2, 3]. If you have multiple primary keys you need to pass object with property names and values specified, for example [{ firstId: 1, secondId: 2 }, { firstId: 2, secondId: 3 }, ...]

      参数

      • ids: any

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

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

      返回 this

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

      参数

      返回 this

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

      参数

      • selection: string
      • 可选selectionAliasName: string

      返回 this

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

      参数

      • selection: string[]

      返回 this

    • 参数

      返回 this

    • Sets locking mode.

      参数

      • lockMode: "optimistic"
      • lockVersion: number | Date

      返回 this

    • Sets locking mode.

      参数

      • lockMode:
            | "pessimistic_read"
            | "pessimistic_write"
            | "dirty_read"
            | "pessimistic_partial_write"
            | "pessimistic_write_or_fail"
            | "for_no_key_update"
            | "for_key_share"
      • 可选lockVersion: undefined
      • 可选lockTables: string[]

      返回 this

    • Adds native parameters from the given object.

      参数

      返回 this

      Use setParameters instead

    • Sets lock handling by adding NO WAIT or SKIP LOCKED.

      参数

      • onLocked: "nowait" | "skip_locked"

      返回 this

    • Sets extra options that can be used to configure how query builder works.

      参数

      • option: SelectQueryBuilderOption

      返回 this

    • 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

    • Sets number of entities to skip.

      参数

      • 可选skip: number

      返回 this

    • 返回 SoftDeleteQueryBuilder<any>

    • Executes built SQL query and returns raw data stream.

      返回 Promise<ReadStream>

    • Creates a subquery - query that can be used inside other queries.

      返回 SelectQueryBuilder<any>

    • Sets maximal number of entities to take.

      参数

      • 可选take: number

      返回 this

    • Enables time travelling for the current query (only supported by cockroach currently)

      参数

      • 可选timeTravelFn: string | boolean

      返回 this

    • Set certain index to be used by the query.

      参数

      • index: string

        Name of index to be used.

      返回 this

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

      参数

      • enabled: boolean

      返回 this

    • Sets WHERE condition in the query builder. If you had previously WHERE expression defined, calling this function will override previously set WHERE conditions. Additionally you can add parameters used in where expression.

      参数

      返回 this

    • Sets a new where EXISTS clause

      参数

      返回 this

    • Adds new AND WHERE with conditions for the given ids.

      Ids are mixed. It means if you have single primary key you can pass a simple id values, for example [1, 2, 3]. If you have multiple primary keys you need to pass object with property names and values specified, for example [{ firstId: 1, secondId: 2 }, { firstId: 2, secondId: 3 }, ...]

      参数

      • ids: any

      返回 this

    • Disables the global condition of "non-deleted" for the entity with delete date columns.

      返回 this

    • 参数

      • name: string
      • factory: any

      返回 void