Protected
constraintsConstraints applied to this query.
Protected
Readonly
databaseProtected
Optional
rawRaw SQL to use instead. Overrides builder methods.
Protected
Optional
registeredThe connection on which the query should be executed.
Protected
registeredIf true, the query should refer to distinct records.
Protected
registeredThe fields to query from the table.
Protected
registeredArray of SQL group-by clauses.
Protected
registeredArray of SQL order-by clauses.
Protected
Optional
registeredThe number of records to skip before the result set.
Protected
Optional
registeredThe max number of records to include in the result set.
Protected
Optional
sourceThe source table to query from.
Private
appThe global application instance.
Get the constraints applied to this query.
True if the query should be DISTINCT
Get the fields that should be included in this query.
Get the SQL group-by clauses applied to this query.
Get the SQL order-by clauses applied to this query.
Get the skip/take values of this query.
Get the source table for this query.
Protected
appGet the global Application.
Clone the current query to a new AbstractBuilder instance with the same properties.
Specify the connection name or instance to execute the query on.
Protected
containerExecute a DELETE based on this query.
query.table('my_table').where('id', <, 44).delete()
This is equivalent to:
DELETE
FROM my_table
WHERE
id < 44
Include the given field (and optional alias) in the query.
Optional
alias: stringInclude the given fields in the query.
Rest
...fields: SpecifiedField[]Get a copy of this builder with its values finalized.
Set the source table (and optional alias) for this query.
Optional
alias: stringGet an async collection of the rows resulting from this query.
Get the method with the given name from this class, bound to this class.
function
Get the method with the given name from this class, bound to this class.
function
Rest
...args: any[]Create a new, empty, instance of the current builder.
Get a result iterable for the built query.
Insert the given rows into the table for this query, returning the fields specified in this query.
const rows = [
{ name: 'A' },
{ name: 'B' },
]
query.table('my_table')
.returning('id', 'name')
.insert(rows)
This is equivalent to:
INSERT INTO my_table (name)
VALUES ('A'), ('B')
RETURNING id, name
Get a result iterable for the rows of this query.
Protected
makeApply an OR WHERE constraint to the query.
Optional
operator: ConstraintOperatorOptional
operand: EscapeValue<ScalarEscapeValue>Apply an OR WHERE IN constraint to the query, escaping the values in the set.
Apply an OR WHERE NOT constraint to the query.
Optional
operator: ConstraintOperatorOptional
operand: EscapeValue<ScalarEscapeValue>Apply an OR WHERE NOT IN constraint to the query, escaping the values in the set.
Apply an OR WHERE constraint to the query, without escaping operand
. Prefer orWhere()
.
Order the query by the given field.
Alias of fields()
.
Rest
...fields: SpecifiedField[]Alias of fields()
.
Rest
...fields: SpecifiedField[]Run an UPDATE query for all rows matched by this query, setting the given data.
query.table('my_table').update({ my_col: 4 })
This is equivalent to:
UPDATE TO my_table
SET
my_col = 4
Run a batch update on all rows matched by this query, setting the values for discrete rows based on some key.
This is a more efficient way of combining discrete update queries.
query.table('my_table')
.updateMany('id_col', [
{id_col: 1, val1_col: 'a'},
{id_col: 2, val2_col: 'b'},
])
This will set the val1_col
to a
for rows where id_col
is 1
and so on.
Apply a new WHERE constraint to the query.
Optional
operator: ConstraintOperatorOptional
operand: EscapeValue<ScalarEscapeValue>Apply a WHERE IN constraint to the query, escaping the values in the set.
Apply a new WHERE NOT constraint to the query.
Optional
operator: ConstraintOperatorOptional
operand: EscapeValue<ScalarEscapeValue>Apply a WHERE NOT IN constraint to the query, escaping the values in the set.
Add raw SQL as a constraint to the query.
Apply a new WHERE constraint to the query, without escaping operand
. Prefer where()
.
Implementation of the abstract builder class that returns simple QueryRow objects.