QueryBuilder can be initialized from given Connection and QueryRunner objects or from given other QueryBuilder.
QueryBuilder can be initialized from given Connection and QueryRunner objects or from given other QueryBuilder.
Connection on which QueryBuilder was created.
Contains all properties of the QueryBuilder that needs to be build a final query.
Query runner used to execute query builder query.
Gets the main alias string used in this query builder.
Specifies FROM which entity's table select/update/delete will be executed. Also sets a main string alias of the selection data.
Specifies FROM which entity's table select/update/delete will be executed. Also sets a main string alias of the selection data.
Adds GROUP BY condition in the query builder.
Adds ORDER BY condition in the query builder.
Adds new selection to the SELECT query.
Adds new selection to the SELECT query.
Adds new selection to the SELECT query.
Adds new AND HAVING condition in the query builder. Additionally you can add parameters used in where expression.
Adds new AND WHERE condition in the query builder. Additionally you can add parameters used in where expression.
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 }, ...]
Builds column alias from given alias name and column name, If alias length is more than 29, abbreviates column name.
Enables or disables query result caching.
Enables query result caching and sets in milliseconds in which cache will expire. If not set then global caching time will be used.
Enables query result caching and sets cache id and milliseconds in which cache will expire.
Indicates if listeners and subscribers must be called before and after query execution. Enabled by default.
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.
Computes given where argument - transforms to a where string all forms it can take.
Specifies FROM which entity's table select/update/delete will be executed. Also sets a main string alias of the selection data.
Creates "GROUP BY" part of SQL query.
Creates "HAVING" part of SQL query.
Creates "JOIN" part of SQL query.
Creates "LIMIT" and "OFFSET" parts of SQL query.
Creates "LOCK" part of SQL query.
Creates "ORDER BY" part of SQL query.
Creates a completely new query builder. Uses same query runner as current QueryBuilder.
Creates "RETURNING" / "OUTPUT" expression.
Creates "SELECT FROM" part of SQL query.
Creates "WHERE" expression.
Concatenates all added where expressions into one string.
Creates "WHERE" expression and variables for the given "ids".
Creates DELETE query.
Disables escaping.
Escapes table name, column name or alias name using current database's escaping character.
Executes sql generated by query builder and returns raw database results.
Executes sql generated by query builder and returns object with raw results and entities created from them.
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.
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.
Gets count - number of entities selected by sql generated by this query builder. Count excludes all limitations set by setFirstResult and setMaxResults methods call.
Gets name of the table where insert should be performed.
Gets entities returned by execution of generated query builder sql.
Executes built SQL query and returns entities and overall entities count (without limitation). This method is useful to build pagination.
Gets single entity returned by execution of generated query builder sql.
Gets all parameters.
Gets generated sql query without parameters being replaced.
Gets query to be executed with all parameters used in it.
Executes sql generated by query builder and returns object with raw results and entities created from them.
Gets all raw results returned by execution of generated query builder sql.
Gets first raw result returned by execution of generated query builder sql.
If returning / output cause is set to array of column names, then this method will return all column metadatas of those column names.
Gets generated sql that will be executed. Parameters in the query are escaped for the currently used driver.
Gets escaped table name with schema name if SqlServer driver used with custom schema name, otherwise returns escaped table name.
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.
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.
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?
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?
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
Creates INSERT query.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
Set's 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 instead take method instead.
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.
Loads raw results from the database.
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.
LEFT JOINs relation id and maps it into some entity's property. Optionally, you can add condition and parameters used in condition.
LEFT JOINs relation id and maps it into some entity's property. Optionally, you can add condition and parameters used in condition.
Merges into expression map given expression map properties.
Normalizes a give number - converts to int if possible.
Creates a query builder used to execute sql queries inside this query builder.
Set's 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 instead skip method instead.
Adds new OR HAVING condition in the query builder. Additionally you can add parameters used in where expression.
Adds new OR WHERE condition in the query builder. Additionally you can add parameters used in where expression.
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 }, ...]
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.
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.
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.
Prints sql to stdout using console.log.
Sets entity's relation with which this query builder gonna work.
Sets entity's relation with which this query builder gonna work.
Replaces all entity's propertyName to name in the given statement.
Creates SELECT query. Replaces all previous selections if they exist.
Creates SELECT query. Replaces all previous selections if they exist.
Creates SELECT query and selects given data. Replaces all previous selections if they exist.
Creates SELECT query and selects given data. Replaces all previous selections if they exist.
Sets locking mode.
Sets locking mode.
Sets locking mode.
Adds native parameters from the given object.
Sets extra options that can be used to configure how query builder works.
Sets parameter name and its value.
Adds all parameters from the given object.
Sets or overrides query builder's QueryRunner.
Sets number of entities to skip.
Executes built SQL query and returns raw data stream.
Creates a subquery - query that can be used inside other queries.
Sets maximal number of entities to take.
Creates UPDATE query and applies given update values.
Creates UPDATE query and applies given update values.
Creates UPDATE query for the given entity and applies given update values.
Creates UPDATE query for the given entity and applies given update values.
Creates UPDATE query for the given entity and applies given update values.
Creates UPDATE query for the given table name and applies given update values.
If set to true the query will be wrapped into a transaction.
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.
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 }, ...]
Generated using TypeDoc
Allows to build complex sql queries in a fashion way and execute those queries.