Skip to main content
Module

x/typeorm/src/query-builder/QueryExpressionMap.ts>QueryExpressionMap

Forked from https://github.com/typeorm/typeorm
Latest
class QueryExpressionMap
import { QueryExpressionMap } from "https://deno.land/x/typeorm@v0.2.23-rc10/src/query-builder/QueryExpressionMap.ts";

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

Constructors

new
QueryExpressionMap(connection: Connection)

Properties

aliases: Alias[]

All aliases (including main alias) used in the query.

aliasNamePrefixingEnabled: boolean

Indicates if property names are prefixed with alias names during property replacement. By default this is enabled, however we need this because aliases are not supported in UPDATE and DELETE queries, but user can use them in WHERE expressions.

readonly
allOrderBys

Get all ORDER BY queries - if order by is specified by user then it uses them, otherwise it uses default entity order by if it was set.

cache: boolean

Indicates if query result cache is enabled or not.

cacheDuration: number

Time in milliseconds in which cache will expire. If not set then global caching time will be used.

cacheId: string

Cache id. Used to identifier your cache queries.

callListeners: boolean

Indicates if listeners and subscribers must be called before and after query execution.

disableEscaping: boolean

Indicates if alias, table names and column names will be ecaped by driver, or not.

todo: rename to isQuotingDisabled, also think if it should be named "escaping"

enableRelationIdValues: boolean

Indicates if virtual columns should be included in entity result.

todo: what to do with it? is it properly used? what about persistence?

extraAppendedAndWhereCondition: string

Extra where condition appended to the end of original where conditions with AND keyword. Original condition will be wrapped into brackets.

extraReturningColumns: ColumnMetadata[]

Extra returning columns to be added to the returning statement if driver supports it.

groupBys: string[]

GROUP BY queries.

havings: { type: "simple" | "and" | "or"; condition: string; }[]

HAVING queries.

insertColumns: string[]

List of columns where data should be inserted. Used in INSERT query.

joinAttributes: JoinAttribute[]

JOIN queries.

optional
limit: number

LIMIT query.

optional
lockMode:
| "optimistic"
| "pessimistic_read"
| "pessimistic_write"
| "dirty_read"

Locking mode.

optional
lockVersion: number | Date

Current version of the entity, used for locking.

optional
mainAlias: Alias

Main alias is a main selection object selected by QueryBuilder.

nativeParameters: ObjectLiteral

Extra parameters. Used in InsertQueryBuilder to avoid default parameters mechanizm and execute high performance insertions.

of: any | any[]

Entity (target) which relations will be updated.

optional
offset: number

OFFSET query.

onConflict: string

Optional on conflict statement used in insertion query in postgres.

onIgnore: string | boolean

Optional on ignore statement used in insertion query in databases.

onUpdate: { columns?: string; conflict?: string; overwrite?: string; }

Optional on update statement used in insertion query in databases.

options: SelectQueryBuilderOption[]

Options that define QueryBuilder behaviour.

orderBys: OrderByCondition

ORDER BY queries.

parameters: ObjectLiteral

Parameters used to be escaped in final query.

parentQueryBuilder: QueryBuilder<any>

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

queryEntity: boolean

Indicates if QueryBuilder used to select entities and not a raw results.

queryType:
| "select"
| "update"
| "delete"
| "insert"
| "relation"

Represents query type. QueryBuilder is able to build SELECT, UPDATE and DELETE queries.

relationCountAttributes: RelationCountAttribute[]

Relation count queries.

relationIdAttributes: RelationIdAttribute[]

RelationId queries.

readonly
relationMetadata: RelationMetadata

Gets relation metadata of the relation this query builder works with.

todo: add proper exceptions

relationPropertyPath: string

Property path of relation to work with. Used in relational query builder.

returning: string | string[]

Optional returning (or output) clause for insert, update or delete queries.

selectDistinct: boolean

Whether SELECT is DISTINCT.

selectDistinctOn: string[]

SELECT DISTINCT ON query (postgres).

selects: SelectQuery[]

Data needs to be SELECT-ed.

optional
skip: number

Number of rows to skip of result using pagination.

subQuery: boolean

Indicates if query builder creates a subquery.

optional
take: number

Number of rows to take using pagination.

updateEntity: boolean

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

useTransaction: boolean

Indicates if query must be wrapped into transaction.

optional
valuesSet: ObjectLiteral | ObjectLiteral[]

If update query was used, it needs "update set" - properties which will be updated by this query. If insert query was used, it needs "insert set" - values that needs to be inserted.

whereEntities: ObjectLiteral[]

Used if user wants to update or delete a specific entities.

wheres: { type: "simple" | "and" | "or"; condition: string; }[]

WHERE queries.

Methods

clone(): QueryExpressionMap

Copies all properties of the current QueryExpressionMap into a new one. Useful when QueryBuilder needs to create a copy of itself.

createAlias(options: { type:
| "from"
| "select"
| "join"
| "other"
; name?: string; target?: Function | string; tablePath?: string; subQuery?: string; metadata?: EntityMetadata; }
): Alias

Creates a new alias and adds it to the current expression map.

findAliasByName(aliasName: string): Alias

Finds alias with the given name. If alias was not found it throw an exception.

findColumnByAliasExpression(aliasExpression: string): ColumnMetadata | undefined
setMainAlias(alias: Alias): Alias

Creates a main alias and adds it to the current expression map.