Skip to main content
Module

x/typeorm/src/index.ts>UpdateQueryBuilder

Forked from https://github.com/typeorm/typeorm
Latest
class UpdateQueryBuilder
implements WhereExpression
extends QueryBuilder<Entity>
import { UpdateQueryBuilder } from "https://deno.land/x/typeorm@v0.2.23-rc10/src/index.ts";

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

Constructors

new
UpdateQueryBuilder(
queryBuilderFactory: AbstractQueryBuilderFactory,
connectionOrQueryBuilder: Connection | QueryBuilder<any>,
queryRunner?: QueryRunner,
)

Methods

protected
createLimitExpression(): string

Creates "LIMIT" parts of SQL query.

Creates "ORDER BY" part of SQL query.

Creates UPDATE express used to perform insert query.

protected
getValueSet(): ObjectLiteral

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

addOrderBy(
sort: string,
order?: "ASC" | "DESC",
nulls?: "NULLS FIRST" | "NULLS LAST",
): this

Adds ORDER BY condition in the query builder.

andWhere(where: string | ((qb: this) => string) | Brackets, parameters?: ObjectLiteral): this

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

andWhereInIds(ids: any | any[]): this

Adds new AND WHERE with conditions for the given ids.

execute(): Promise<UpdateResult>

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

getQuery(): string

Gets generated sql query without parameters being replaced.

limit(limit?: number): this

Sets LIMIT - maximum number of rows to be selected.

orderBy(): 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.

orderBy(
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.

orderBy(order: OrderByCondition): 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.

orWhere(where: string | ((qb: this) => string) | Brackets, parameters?: ObjectLiteral): this

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

orWhereInIds(ids: any | any[]): this

Adds new OR WHERE with conditions for the given ids.

output(columns: string[]): this

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

output(output: string): this

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

output(output: string | string[]): this

Optional returning/output clause.

returning(columns: string[]): this

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

returning(returning: string): this

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

returning(returning: string | string[]): this

Optional returning/output clause.

set(values: QueryDeepPartialEntity<Entity>): this

Values needs to be updated.

updateEntity(enabled: boolean): this

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

where(where:
| string
| ((qb: this) => string)
| Brackets
| ObjectLiteral
| ObjectLiteral[]
, parameters?: ObjectLiteral
): 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.

whereEntity(entity: Entity | Entity[]): this

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

whereInIds(ids: any | any[]): this

Adds new AND WHERE with conditions for the given ids.