The aggregate function for this query. If this is set, it is assumed
that this query selects of format SELECT fun(columns) AS aggregate
.
The columns we are currently retrieving.
All the GROUP BY columns for the query.
If we are only looking for distinct values.
All joins for the current query.
The LIMIT clause for the query, or -1 if not applicable.
The constructor of the model we are currently querying. If this is non-null, we are still operating on the full model (no narrowed down views) which means that once we have fetched the objects we can assign this prototype to ensure that the returned instance supports any user-defined methods (along with defaults such as save).
All the ORDER BY clauses for the query.
Which table we are currently querying.
All where clauses for the current query.
Runs the specified aggregate function and returns the result.
Alias for get().
Returns the average of the specified column, or the current column by default.
Counts the amount of rows matching.
Used as a helper function to create a new instance of ourselves. Mainly used in nested where/on clauses. Must be overridden by subclasses.
Deletes all rows matching the current query.
Marks this query as looking for distinct values. Use distinct(false) to undo.
Checks if any rows exist that match the current query. Alias for count > 0.
Finds the first row with the specified ID. Alias for where("id", id).first()
Returns the first row matching this query.
Changes the table this query is currently acting on to the table associated with the specified model.
Changes the table this query is currently acting on to the specified table. An optional type parameter can be used to set the scheme of the table so that further operations are as type-safe as possible.
Returns all rows matching the current query.
Marks the query to group the results by the provided column names.
Inserts the specified entries in the current table.
Essentially the same as insert()
, but returns the ID of the inserted
row and only supports inserting a single row at a time.
Adds a new INNER JOIN with the specified table on the specified columns and operators. This operation loses type-safety since it is impossible to determine the return type of the join statically.
Adds a new nested INNER JOIN with the specified table. The handler receives a JoinClause which it can use to build the new join.
Adds a new INNER JOIN with the specified model and the specified columns and operator. This operation is type safe and returns a union of the current fields and the fields of the specified model.
Adds a new nested INNER JOIN with the specified model. The handler receives a JoinClause which it can use to build the new join. This operation is type safe and returns a union of the current fields and the fields of the specified model.
Adds a new LEFT JOIN with the specified table on the specified columns and operators. This operation loses type-safety since it is impossible to determine the return type of the join statically.
Adds a new nested LEFT JOIN with the specified table. The handler receives a JoinClause which it can use to build the new join.
Adds a new LEFT JOIN with the specified model and the specified columns and operator. This operation is type safe and returns a union of the current fields and the fields of the specified model.
Adds a new nested LEFT JOIN with the specified model. The handler receives a JoinClause which it can use to build the new join. This operation is type safe and returns a union of the current fields and the fields of the specified model.
Limits the amount of rows this query targets to the specified amount. Must be positive non-null.
Returns the maximum value of the specified column, or the current column by default.
Returns the minimum value of the specified column, or the current column by default.
Creates a new nested WHERE OR clause. The specified callback receives a nested query builder that can be used to build the nested queries.
Adds a new WHERE OR clause for the specified column, requiring that it matches the specified variable. This is an alias for where(column, "=", value).
Adds a new WHERE OR clause for the specified column, operator and value. Use
where
if you want to add a WHERE AND clause instead.
Adds a new WHERE OR clause comparing two columns of the current query. This uses
OR, use whereColumn
if you want AND instead.
Adds a new nested WHERE OR query. The handler receives a new QueryBuilder that can be used to enter the where clauses of the nested where.
Adds a new WHERE OR clause asserting that the specified column is NOT NULL.
Adds a new WHERE OR clause asserting that the specified column is NULL.
Adds a new raw WHERE OR clause for the current query. You can use ? as a substitute for arguments to securely bind parameters.
Marks the query to order the results by the specified column in the specified direction, or ASC (ascending) by default.
Marks the query to order the results by the specified column in ascending direction.
Marks the query to order the results by the specified column in descending direction.
Returns only the specified column of all rows this query currently targets.
Adds a new RIGHT JOIN with the specified table on the specified columns and operators. This operation loses type-safety since it is impossible to determine the return type of the join statically.
Adds a new nested RIGHT JOIN with the specified table. The handler receives a JoinClause which it can use to build the new join.
Adds a new RIGHT JOIN with the specified model and the specified columns and operator. This operation is type safe and returns a union of the current fields and the fields of the specified model.
Adds a new nested RIGHT JOIN with the specified model. The handler receives a JoinClause which it can use to build the new join. This operation is type safe and returns a union of the current fields and the fields of the specified model.
Narrows this query down to the specified fields. This erases type- safety since raw SQL queries can be used. Do not use with untrusted input.
Returns the sum of the specified column, or the current column by default.
Updates the specified values for all rows matching the current query.
Returns the specified column of the first result returned by this query.
Creates a new nested where clause. The specified callback receives a nested query builder that can be used to build the nested queries.
Adds a new where clause for the specified column, requiring that it matches the specified variable. This is an alias for where(column, "=", value).
Adds a new where clause for the specified column, operator and value. Optionally
you can provide a QueryBoolean of "OR" instead of "AND", but it is recommended that
you use orWhere
instead.
Adds a new where clause comparing two columns of the current query. This uses
AND as boolean by default, use orWhereColumn
if you want OR instead.
Adds a new nested where query. The handler receives a new QueryBuilder that can be used to enter the where clauses of the nested where.
Adds a new where clause asserting that the specified column is NOT NULL.
Adds a new where clause asserting that the specified column is NULL.
Adds a new raw where clause for the current query. You can use ? as a substitute for arguments to securely bind parameters.
Executes the specified raw query.
Creates a new QueryBuilder referencing the specified model.
Creates a new QueryBuilder referencing the specified table.
Generated using TypeDoc
A fluid SQL query builder that is semi-typesafe and supports selecting, inserting, updating and deleting. Obtain an instance using the static methods or one of the methods on wrapped models.