Class: WhereClause<T>
Defined in: src/query/WhereClause.ts:87
Fluent builder for constructing SQL WHERE filter conditions.
Provides type-safe comparison operators, pattern matching, range queries, nested grouped expressions, JSON path inspection, and full-text search.
Type Parameters
| Type Parameter | Default type |
|---|---|
T | any |
Constructors
Constructor
new WhereClause<
T>():WhereClause<T>
Returns
WhereClause<T>
Methods
and()
and():
this
Defined in: src/query/WhereClause.ts:97
Sets the conjunction operator for the next condition to AND (the default).
Returns
this
this instance for method chaining.
Usecase
Explicitly combine conditions with logical AND.
or()
or():
this
Defined in: src/query/WhereClause.ts:112
Sets the conjunction operator for the next condition to OR.
Returns
this
this instance for method chaining.
Usecase
Combine conditions where at least one must evaluate to true.
Example
query.where(w => w.eq('role', 'admin').or().eq('role', 'manager'));
eq()
Call Signature
eq<
V>(selector,value):this
Defined in: src/query/WhereClause.ts:129
Adds an equality condition (column = value).
Type Parameters
| Type Parameter |
|---|
V |
Parameters
| Parameter | Type | Description |
|---|---|---|
selector | (entity) => V | Property selector function or column name. |
value | V | Expected value. |
Returns
this
this instance for method chaining.
Usecase
Filter records where a property exactly matches a specified value.
Example
w.eq(u => u.status, 'active')
Call Signature
eq<
K>(column,value):this
Defined in: src/query/WhereClause.ts:130
Adds an equality condition (column = value).
Type Parameters
| Type Parameter |
|---|
K extends string |
Parameters
| Parameter | Type | Description |
|---|---|---|
column | K | - |
value | T[K] | Expected value. |
Returns
this
this instance for method chaining.
Usecase
Filter records where a property exactly matches a specified value.
Example
w.eq(u => u.status, 'active')
Call Signature
eq(
column,value):this
Defined in: src/query/WhereClause.ts:131
Adds an equality condition (column = value).
Parameters
| Parameter | Type | Description |
|---|---|---|
column | string & object | - |
value | unknown | Expected value. |
Returns
this
this instance for method chaining.
Usecase
Filter records where a property exactly matches a specified value.
Example
w.eq(u => u.status, 'active')
ne()
Call Signature
ne<
V>(selector,value):this
Defined in: src/query/WhereClause.ts:148
Adds an inequality condition (column <> value).
Type Parameters
| Type Parameter |
|---|
V |
Parameters
| Parameter | Type | Description |
|---|---|---|
selector | (entity) => V | Property selector function or column name. |
value | V | Value to exclude. |
Returns
this
this instance for method chaining.
Usecase
Filter out records matching an undesirable value.
Example
w.ne('status', 'banned')
Call Signature
ne<
K>(column,value):this
Defined in: src/query/WhereClause.ts:149
Adds an inequality condition (column <> value).
Type Parameters
| Type Parameter |
|---|
K extends string |
Parameters
| Parameter | Type | Description |
|---|---|---|
column | K | - |
value | T[K] | Value to exclude. |
Returns
this
this instance for method chaining.
Usecase
Filter out records matching an undesirable value.
Example
w.ne('status', 'banned')
Call Signature
ne(
column,value):this
Defined in: src/query/WhereClause.ts:150
Adds an inequality condition (column <> value).
Parameters
| Parameter | Type | Description |
|---|---|---|
column | string & object | - |
value | unknown | Value to exclude. |
Returns
this
this instance for method chaining.
Usecase
Filter out records matching an undesirable value.
Example
w.ne('status', 'banned')
gt()
Call Signature
gt<
V>(selector,value):this
Defined in: src/query/WhereClause.ts:163
Adds a greater-than comparison (column > value).
Type Parameters
| Type Parameter |
|---|
V |
Parameters
| Parameter | Type | Description |
|---|---|---|
selector | (entity) => V | Property selector function or column name. |
value | V | Threshold value. |
Returns
this
this instance for method chaining.
Usecase
Numeric thresholds, date cutoffs, or price minimums.
Call Signature
gt<
K>(column,value):this
Defined in: src/query/WhereClause.ts:164
Adds a greater-than comparison (column > value).
Type Parameters
| Type Parameter |
|---|
K extends string |
Parameters
| Parameter | Type | Description |
|---|---|---|
column | K | - |
value | T[K] | Threshold value. |
Returns
this
this instance for method chaining.
Usecase
Numeric thresholds, date cutoffs, or price minimums.
Call Signature
gt(
column,value):this
Defined in: src/query/WhereClause.ts:165
Adds a greater-than comparison (column > value).
Parameters
| Parameter | Type | Description |
|---|---|---|
column | string & object | - |
value | unknown | Threshold value. |
Returns
this
this instance for method chaining.
Usecase
Numeric thresholds, date cutoffs, or price minimums.
gte()
Call Signature
gte<
V>(selector,value):this
Defined in: src/query/WhereClause.ts:178
Adds a greater-than-or-equal comparison (column >= value).
Type Parameters
| Type Parameter |
|---|
V |
Parameters
| Parameter | Type | Description |
|---|---|---|
selector | (entity) => V | Property selector function or column name. |
value | V | Minimum inclusive value. |
Returns
this
this instance for method chaining.
Usecase
Inclusive lower bounds on numbers and dates.
Call Signature
gte<
K>(column,value):this
Defined in: src/query/WhereClause.ts:179
Adds a greater-than-or-equal comparison (column >= value).
Type Parameters
| Type Parameter |
|---|
K extends string |
Parameters
| Parameter | Type | Description |
|---|---|---|
column | K | - |
value | T[K] | Minimum inclusive value. |
Returns
this
this instance for method chaining.
Usecase
Inclusive lower bounds on numbers and dates.
Call Signature
gte(
column,value):this
Defined in: src/query/WhereClause.ts:180
Adds a greater-than-or-equal comparison (column >= value).
Parameters
| Parameter | Type | Description |
|---|---|---|
column | string & object | - |
value | unknown | Minimum inclusive value. |
Returns
this
this instance for method chaining.
Usecase
Inclusive lower bounds on numbers and dates.
lt()
Call Signature
lt<
V>(selector,value):this
Defined in: src/query/WhereClause.ts:193
Adds a less-than comparison (column < value).
Type Parameters
| Type Parameter |
|---|
V |
Parameters
| Parameter | Type | Description |
|---|---|---|
selector | (entity) => V | Property selector function or column name. |
value | V | Threshold value. |
Returns
this
this instance for method chaining.
Usecase
Upper bounds, maximum limits, or dates strictly prior to cutoff.
Call Signature
lt<
K>(column,value):this
Defined in: src/query/WhereClause.ts:194
Adds a less-than comparison (column < value).
Type Parameters
| Type Parameter |
|---|
K extends string |
Parameters
| Parameter | Type | Description |
|---|---|---|
column | K | - |
value | T[K] | Threshold value. |
Returns
this
this instance for method chaining.
Usecase
Upper bounds, maximum limits, or dates strictly prior to cutoff.
Call Signature
lt(
column,value):this
Defined in: src/query/WhereClause.ts:195
Adds a less-than comparison (column < value).
Parameters
| Parameter | Type | Description |
|---|---|---|
column | string & object | - |
value | unknown | Threshold value. |
Returns
this
this instance for method chaining.
Usecase
Upper bounds, maximum limits, or dates strictly prior to cutoff.
lte()
Call Signature
lte<
V>(selector,value):this
Defined in: src/query/WhereClause.ts:208
Adds a less-than-or-equal comparison (column <= value).
Type Parameters
| Type Parameter |
|---|
V |
Parameters
| Parameter | Type | Description |
|---|---|---|
selector | (entity) => V | Property selector function or column name. |
value | V | Maximum inclusive value. |
Returns
this
this instance for method chaining.
Usecase
Inclusive upper bounds on numbers and dates.
Call Signature
lte<
K>(column,value):this
Defined in: src/query/WhereClause.ts:209
Adds a less-than-or-equal comparison (column <= value).
Type Parameters
| Type Parameter |
|---|
K extends string |
Parameters
| Parameter | Type | Description |
|---|---|---|
column | K | - |
value | T[K] | Maximum inclusive value. |
Returns
this
this instance for method chaining.
Usecase
Inclusive upper bounds on numbers and dates.
Call Signature
lte(
column,value):this
Defined in: src/query/WhereClause.ts:210
Adds a less-than-or-equal comparison (column <= value).
Parameters
| Parameter | Type | Description |
|---|---|---|
column | string & object | - |
value | unknown | Maximum inclusive value. |
Returns
this
this instance for method chaining.
Usecase
Inclusive upper bounds on numbers and dates.
like()
Call Signature
like(
selector,pattern):this
Defined in: src/query/WhereClause.ts:227
Adds a pattern-matching condition (column LIKE pattern).
Parameters
| Parameter | Type | Description |
|---|---|---|
selector | (entity) => unknown | Property selector function or column name. |
pattern | string | SQL wildcard pattern (e.g. '%example.com'). |
Returns
this
this instance for method chaining.
Usecase
Substring search or prefix/suffix wildcard matching with % and _.
Example
w.like('email', '%@company.org')
Call Signature
like(
column,pattern):this
Defined in: src/query/WhereClause.ts:228
Adds a pattern-matching condition (column LIKE pattern).
Parameters
| Parameter | Type | Description |
|---|---|---|
column | ColumnKey<T> | - |
pattern | string | SQL wildcard pattern (e.g. '%example.com'). |
Returns
this
this instance for method chaining.
Usecase
Substring search or prefix/suffix wildcard matching with % and _.
Example
w.like('email', '%@company.org')
notLike()
Call Signature
notLike(
selector,pattern):this
Defined in: src/query/WhereClause.ts:241
Adds a negative pattern-matching condition (column NOT LIKE pattern).
Parameters
| Parameter | Type | Description |
|---|---|---|
selector | (entity) => unknown | Property selector function or column name. |
pattern | string | SQL wildcard pattern. |
Returns
this
this instance for method chaining.
Usecase
Exclude records matching a specific wildcard pattern.
Call Signature
notLike(
column,pattern):this
Defined in: src/query/WhereClause.ts:242
Adds a negative pattern-matching condition (column NOT LIKE pattern).
Parameters
| Parameter | Type | Description |
|---|---|---|
column | ColumnKey<T> | - |
pattern | string | SQL wildcard pattern. |
Returns
this
this instance for method chaining.
Usecase
Exclude records matching a specific wildcard pattern.
in()
Call Signature
in<
V>(selector,values):this
Defined in: src/query/WhereClause.ts:259
Adds a set inclusion test (column IN (...)).
Type Parameters
| Type Parameter |
|---|
V |
Parameters
| Parameter | Type | Description |
|---|---|---|
selector | (entity) => V | Property selector function or column name. |
values | V[] | Array of matching values. |
Returns
this
this instance for method chaining.
Usecase
Filter records whose column matches any element in an array of candidate values.
Example
w.in('status', ['pending', 'processing', 'review'])
Call Signature
in<
K>(column,values):this
Defined in: src/query/WhereClause.ts:260
Adds a set inclusion test (column IN (...)).
Type Parameters
| Type Parameter |
|---|
K extends string |
Parameters
| Parameter | Type | Description |
|---|---|---|
column | K | - |
values | T[K][] | Array of matching values. |
Returns
this
this instance for method chaining.
Usecase
Filter records whose column matches any element in an array of candidate values.
Example
w.in('status', ['pending', 'processing', 'review'])
Call Signature
in(
column,values):this
Defined in: src/query/WhereClause.ts:261
Adds a set inclusion test (column IN (...)).
Parameters
| Parameter | Type | Description |
|---|---|---|
column | string & object | - |
values | unknown[] | Array of matching values. |
Returns
this
this instance for method chaining.
Usecase
Filter records whose column matches any element in an array of candidate values.
Example
w.in('status', ['pending', 'processing', 'review'])
notIn()
Call Signature
notIn<
V>(selector,values):this
Defined in: src/query/WhereClause.ts:274
Adds a set exclusion test (column NOT IN (...)).
Type Parameters
| Type Parameter |
|---|
V |
Parameters
| Parameter | Type | Description |
|---|---|---|
selector | (entity) => V | Property selector function or column name. |
values | V[] | Array of excluded values. |
Returns
this
this instance for method chaining.
Usecase
Exclude records whose column matches any element in an array of values.
Call Signature
notIn<
K>(column,values):this
Defined in: src/query/WhereClause.ts:275
Adds a set exclusion test (column NOT IN (...)).
Type Parameters
| Type Parameter |
|---|
K extends string |
Parameters
| Parameter | Type | Description |
|---|---|---|
column | K | - |
values | T[K][] | Array of excluded values. |
Returns
this
this instance for method chaining.
Usecase
Exclude records whose column matches any element in an array of values.
Call Signature
notIn(
column,values):this
Defined in: src/query/WhereClause.ts:276
Adds a set exclusion test (column NOT IN (...)).
Parameters
| Parameter | Type | Description |
|---|---|---|
column | string & object | - |
values | unknown[] | Array of excluded values. |
Returns
this
this instance for method chaining.
Usecase
Exclude records whose column matches any element in an array of values.
isNull()
Call Signature
isNull(
selector):this
Defined in: src/query/WhereClause.ts:288
Adds an IS NULL condition.
Parameters
| Parameter | Type | Description |
|---|---|---|
selector | (entity) => unknown | Property selector function or column name. |
Returns
this
this instance for method chaining.
Usecase
Filter records where a nullable column has no assigned value.
Call Signature
isNull(
column):this
Defined in: src/query/WhereClause.ts:289
Adds an IS NULL condition.
Parameters
| Parameter | Type |
|---|---|
column | ColumnKey<T> |
Returns
this
this instance for method chaining.
Usecase
Filter records where a nullable column has no assigned value.
isNotNull()
Call Signature
isNotNull(
selector):this
Defined in: src/query/WhereClause.ts:301
Adds an IS NOT NULL condition.
Parameters
| Parameter | Type | Description |
|---|---|---|
selector | (entity) => unknown | Property selector function or column name. |
Returns
this
this instance for method chaining.
Usecase
Filter records where a nullable column contains a value.
Call Signature
isNotNull(
column):this
Defined in: src/query/WhereClause.ts:302
Adds an IS NOT NULL condition.
Parameters
| Parameter | Type |
|---|---|
column | ColumnKey<T> |
Returns
this
this instance for method chaining.
Usecase
Filter records where a nullable column contains a value.
between()
Call Signature
between<
V>(selector,start,end):this
Defined in: src/query/WhereClause.ts:320
Adds an inclusive range condition (column BETWEEN start AND end).
Type Parameters
| Type Parameter |
|---|
V |
Parameters
| Parameter | Type | Description |
|---|---|---|
selector | (entity) => V | Property selector function or column name. |
start | V | Lower range boundary (inclusive). |
end | V | Upper range boundary (inclusive). |
Returns
this
this instance for method chaining.
Usecase
Filter date ranges or numeric ranges cleanly without separate >= and <= calls.
Example
w.between('price', 10, 50)
Call Signature
between<
K>(column,start,end):this
Defined in: src/query/WhereClause.ts:321
Adds an inclusive range condition (column BETWEEN start AND end).
Type Parameters
| Type Parameter |
|---|
K extends string |
Parameters
| Parameter | Type | Description |
|---|---|---|
column | K | - |
start | T[K] | Lower range boundary (inclusive). |
end | T[K] | Upper range boundary (inclusive). |
Returns
this
this instance for method chaining.
Usecase
Filter date ranges or numeric ranges cleanly without separate >= and <= calls.
Example
w.between('price', 10, 50)
Call Signature
between(
column,start,end):this
Defined in: src/query/WhereClause.ts:322
Adds an inclusive range condition (column BETWEEN start AND end).
Parameters
| Parameter | Type | Description |
|---|---|---|
column | string & object | - |
start | unknown | Lower range boundary (inclusive). |
end | unknown | Upper range boundary (inclusive). |
Returns
this
this instance for method chaining.
Usecase
Filter date ranges or numeric ranges cleanly without separate >= and <= calls.
Example
w.between('price', 10, 50)
group()
group(
builderFn):this
Defined in: src/query/WhereClause.ts:338
Groups a set of conditions enclosed in parentheses (cond1 OR cond2).
Parameters
| Parameter | Type | Description |
|---|---|---|
builderFn | (subClause) => void | Callback receiving a sub-WhereClause builder. |
Returns
this
this instance for method chaining.
Usecase
Control operator precedence when mixing AND with OR logic.
Example
w.eq('isActive', true).and().group(g => g.eq('tier', 'gold').or().gt('points', 1000));
whereJson()
whereJson(
column,path,operatorOrValue,value?):this
Defined in: src/query/WhereClause.ts:361
Adds a filter inside a JSON/JSONB document property.
Parameters
| Parameter | Type | Description |
|---|---|---|
column | ColumnKey<T> | ((entity) => unknown) | Property containing the JSON payload. |
path | string | Dot-separated path inside the JSON object (e.g. 'address.zip'). |
operatorOrValue | unknown | Comparison operator (e.g. '=', '>') or target value when testing equality. |
value? | unknown | Target value if operator was supplied. |
Returns
this
this instance for method chaining.
Usecase
Query nested attributes inside JSON columns with database dialect-specific operators.
json()
json(
column,path,operatorOrValue,value?):this
Defined in: src/query/WhereClause.ts:390
Shorthand alias for whereJson.
Parameters
| Parameter | Type |
|---|---|
column | ColumnKey<T> | ((entity) => unknown) |
path | string |
operatorOrValue | unknown |
value? | unknown |
Returns
this
Usecase
Filter nested attributes inside JSON columns.
whereSearch()
whereSearch(
columns,query,options?):this
Defined in: src/query/WhereClause.ts:408
Adds native full-text search condition across multiple columns.
Parameters
| Parameter | Type | Description |
|---|---|---|
columns | (ColumnKey<T> | ((entity) => unknown))[] | Columns or property selectors to search across. |
query | string | Search keywords. |
options? | SearchOptions | Full-text options (search mode, language). |
Returns
this
this instance for method chaining.
Usecase
Implement keyword search with database-native indexing across text fields.
search()
search(
columns,query,options?):this
Defined in: src/query/WhereClause.ts:431
Shorthand alias for whereSearch.
Parameters
| Parameter | Type |
|---|---|
columns | (ColumnKey<T> | ((entity) => unknown))[] |
query | string |
options? | SearchOptions |
Returns
this
Usecase
Full-text search across text columns.
raw()
raw(
sql,params?):this
Defined in: src/query/WhereClause.ts:447
Injects a raw SQL WHERE condition with parameterized values.
Parameters
| Parameter | Type | Description |
|---|---|---|
sql | string | Raw SQL condition string. |
params? | unknown[] | Optional parameter array. |
Returns
this
this instance for method chaining.
Usecase
Vendor-specific functions, geospatial expressions, or math calculations.
exists()
exists(
subquery,joinPredicate?):this
Defined in: src/query/WhereClause.ts:468
Adds an SQL EXISTS (SELECT ...) subquery condition.
Parameters
| Parameter | Type | Description |
|---|---|---|
subquery | any | QueryBuilder, Subquery instance, or SQL string. |
joinPredicate? | (outer, inner) => void | Callback defining join predicate between outer entity and subquery alias. |
Returns
this
this instance for method chaining.
Example
w.exists(highValueCustomers, (order, hvc) => order.customerId.eq(hvc.id));
notExists()
notExists(
subquery,joinPredicate?):this
Defined in: src/query/WhereClause.ts:488
Adds an SQL NOT EXISTS (SELECT ...) subquery condition.
Parameters
| Parameter | Type | Description |
|---|---|---|
subquery | any | QueryBuilder, Subquery instance, or SQL string. |
joinPredicate? | (outer, inner) => void | Callback defining join predicate between outer entity and subquery alias. |
Returns
this
this instance for method chaining.
Properties
conditions
readonlyconditions:WhereCondition[] =[]
Defined in: src/query/WhereClause.ts:88