Clauses
@quik/database / Clauses
Variable: Clauses
constClauses:object
Defined in: database/src/repository/QWhereClauses.ts:247
Collection of clause factory functions Provides a convenient way to create where builders with various types of clauses
Type Declaration
And
And: (...
conditions) =>QWhereBuilder=AndClause
Creates a new QWhereBuilder that joins conditions with AND logic.
This function is equivalent to calling QWhereBuilder.And and is useful for quickly generating conjunctions of conditions. Use it to ensure all provided conditions must be satisfied for a record to match.
Parameters
conditions
...QWhereCondition[]
Conditions or builders to combine with AND
Returns
Example
const clause = AndClause(
{ field: 'isActive', operator: 'eq', value: true },
{ field: 'role', operator: 'eq', value: 'user' },
);
// WHERE isActive = true AND role = 'user'
Between
Between: (
field,min,max) =>QWhereBuilder=BetweenClause
Creates a builder that checks if a field is within a range.
Parameters
field
string
Field name to check
min
unknown
Minimum value (inclusive)
max
unknown
Maximum value (inclusive)
Returns
Example
const clause = BetweenClause('age', 18, 30);
// WHERE age BETWEEN 18 AND 30
Equal
Equal: (
field,value) =>QWhereBuilder=EqualClause
Creates a builder with a simple equality check.
Parameters
field
string
Field name to compare
value
unknown
Value to compare against
Returns
Example
const clause = EqualClause('status', 'active');
// WHERE status = 'active'
GreaterThan
GreaterThan: (
field,value) =>QWhereBuilder=GreaterThanClause
Creates a builder with a field > value comparison.
Parameters
field
string
Field name to compare
value
unknown
Value to compare against
Returns
GreaterThanOrEqual
GreaterThanOrEqual: (
field,value) =>QWhereBuilder=GreaterThanOrEqualClause
Creates a builder with a field >= value comparison.
Parameters
field
string
Field name to compare
value
unknown
Value to compare against
Returns
In
In: (
field,value) =>QWhereBuilder=InClause
Creates a builder that checks if a field's value exists in a list.
Parameters
field
string
Field name to check
value
unknown[]
Array of values to check against
Returns
Example
const clause = InClause('role', ['admin', 'user']);
// WHERE role IN ('admin', 'user')
IsNull
IsNull: (
field) =>QWhereBuilder=IsNullClause
Creates a builder that checks if a field is NULL.
Parameters
field
string
Field name to check
Returns
LessThan
LessThan: (
field,value) =>QWhereBuilder=LessThanClause
Creates a builder with a field < value comparison.
Parameters
field
string
Field name to compare
value
unknown
Value to compare against
Returns
LessThanOrEqual
LessThanOrEqual: (
field,value) =>QWhereBuilder=LessThanOrEqualClause
Creates a builder with a field <= value comparison.
Parameters
field
string
Field name to compare
value
unknown
Value to compare against
Returns
Like
Like: (
field,value) =>QWhereBuilder=LikeClause
Creates a builder with a LIKE pattern match.
Parameters
field
string
Field name to check
value
unknown
Pattern to match against
Returns
Example
const clause = LikeClause('name', 'A%');
// WHERE name LIKE 'A%'
Not
Not: (
fieldOrCondition,value?,operator?) =>QWhereBuilder=NotClause
Creates a builder with a negated condition.
This helper wraps QWhereBuilder.Not so that you can quickly negate either an existing condition or a new field comparison.
Parameters
fieldOrCondition
string | QWhereCondition
Field name or existing condition to negate
value?
string
Value to compare against when using a field name
operator?
Operator to use when creating a new condition
Returns
NotEqual
NotEqual: (
field,value) =>QWhereBuilder=NotEqualClause
Creates a builder with a not-equal comparison.
Parameters
field
string
Field name to compare
value
unknown
Value to compare against
Returns
Example
const clause = NotEqualClause('status', 'inactive');
// WHERE status <> 'inactive'
NotLike
NotLike: (
field,value) =>QWhereBuilder=NotLikeClause
Creates a builder with a negated LIKE condition.
Parameters
field
string
Field name to check
value
unknown
Pattern to not match against
Returns
Example
const clause = NotLikeClause('name', '%test%');
// WHERE NOT name LIKE '%test%'
NotNull
NotNull: (
field) =>QWhereBuilder=NotNullClause
Creates a builder that checks if a field is NOT NULL.
Parameters
field
string
Field name to check
Returns
Or
Or: (...
conditions) =>QWhereBuilder=OrClause
Creates a new QWhereBuilder that joins conditions with OR logic.
This helper mirrors the QWhereBuilder.Or method and provides a concise way to build a disjunction of conditions. Each parameter can be a plain condition object or an existing where builder, allowing complex combinations.
Parameters
conditions
...QWhereCondition[]
Conditions or builders to combine with OR
Returns
Example
const clause = OrClause(
{ field: 'status', operator: 'eq', value: 'active' },
{ field: 'role', operator: 'eq', value: 'admin' },
);
// WHERE status = 'active' OR role = 'admin'
Typed()
Typed<
TModel>():QTypedClauses<TModel>
Returns a typed view of the clause helpers for a specific model.
Use this when you want field-name autocomplete based on the model type:
const where = Clauses.Typed<User>().Equal('email', 'demo@example.com');
Type Parameters
TModel
TModel extends QModel
Returns
QTypedClauses<TModel>