whereTyped
Description
whereTyped
is a method that applies typesafe condition to a query.
Signature
whereTyped(
selection: KeyProxyCallback<Entity>,
condition?: string,
params?: Record <string, unknown>
): SelectQueryBuilder<Entity>
Arguments
- selection: KeyProxyCallback<Entity>: The callback which selects fields of entity.
- condition?: string: Condition query with operator and value.
- params?: Record <string, unknown>: Parameters for the condition.
Usage
// same as `query.where('user.name LIKE :name', { name: '%John%' })`
query
.whereTyped(
user => user.name,
'LIKE :name',
{ name: '%John%' },
)
// same as `query.andWhere('user.name LIKE :name', { name: '%Doe%' })`
query
.andWhereTyped(
user => user.name,
'LIKE :name',
{ name: '%Doe%' },
)
// same as `query.orWhere('user.name LIKE :name', { name: '%John Doe%' })`
query
.orWhereTyped(
user => user.name,
'LIKE :name',
{ name: '%John Doe%' },
)