Skip to main content

Interface: FilterBuilder<TableInfo>

server.FilterBuilder

An interface for defining filters in queries.

FilterBuilder has various methods that produce Expressions. These expressions can be nested together along with constants to express a filter predicate.

FilterBuilder is used within filter to create query filters.

Here are the available methods:

ComparisonsError when l and r are not the same type.
eq(l, r)l === r
neq(l, r)l !== r
lt(l, r)l < r
lte(l, r)l <= r
gt(l, r)l > r
gte(l, r)l >= r
ArithmeticError when l and r are not the same type.
add(l, r)l + r
sub(l, r)l - r
mul(l, r)l * r
div(l, r)l / r
mod(l, r)l % r
neg(x)-x
LogicError if any param is not a bool.
not(x)!x
and(a, b, ..., z)a && b && ... && z
or(a, b, ..., z)a || b || ... || z
Other
field(fieldPath)Evaluates to the field at fieldPath.

Type parameters

NameType
TableInfoextends GenericTableInfo

Methods

eq

eq<T>(l, r): Expression<boolean>

l === r

Type parameters

NameType
Textends Value

Parameters

NameType
lExpressionOrValue<T>
rExpressionOrValue<T>

Returns

Expression<boolean>


neq

neq<T>(l, r): Expression<boolean>

l !== r

Type parameters

NameType
Textends Value

Parameters

NameType
lExpressionOrValue<T>
rExpressionOrValue<T>

Returns

Expression<boolean>


lt

lt<T>(l, r): Expression<boolean>

l < r

Type parameters

NameType
Textends Value

Parameters

NameType
lExpressionOrValue<T>
rExpressionOrValue<T>

Returns

Expression<boolean>


lte

lte<T>(l, r): Expression<boolean>

l <= r

Type parameters

NameType
Textends Value

Parameters

NameType
lExpressionOrValue<T>
rExpressionOrValue<T>

Returns

Expression<boolean>


gt

gt<T>(l, r): Expression<boolean>

l > r

Type parameters

NameType
Textends Value

Parameters

NameType
lExpressionOrValue<T>
rExpressionOrValue<T>

Returns

Expression<boolean>


gte

gte<T>(l, r): Expression<boolean>

l >= r

Type parameters

NameType
Textends Value

Parameters

NameType
lExpressionOrValue<T>
rExpressionOrValue<T>

Returns

Expression<boolean>


add

add<T>(l, r): Expression<T>

l + r

Type parameters

NameType
Textends NumericValue

Parameters

NameType
lExpressionOrValue<T>
rExpressionOrValue<T>

Returns

Expression<T>


sub

sub<T>(l, r): Expression<T>

l - r

Type parameters

NameType
Textends NumericValue

Parameters

NameType
lExpressionOrValue<T>
rExpressionOrValue<T>

Returns

Expression<T>


mul

mul<T>(l, r): Expression<T>

l * r

Type parameters

NameType
Textends NumericValue

Parameters

NameType
lExpressionOrValue<T>
rExpressionOrValue<T>

Returns

Expression<T>


div

div<T>(l, r): Expression<T>

l / r

Type parameters

NameType
Textends NumericValue

Parameters

NameType
lExpressionOrValue<T>
rExpressionOrValue<T>

Returns

Expression<T>


mod

mod<T>(l, r): Expression<T>

l % r

Type parameters

NameType
Textends NumericValue

Parameters

NameType
lExpressionOrValue<T>
rExpressionOrValue<T>

Returns

Expression<T>


neg

neg<T>(x): Expression<T>

-x

Type parameters

NameType
Textends NumericValue

Parameters

NameType
xExpressionOrValue<T>

Returns

Expression<T>


and

and(...exprs): Expression<boolean>

exprs[0] && exprs[1] && ... && exprs[n]

Parameters

NameType
...exprsExpressionOrValue<boolean>[]

Returns

Expression<boolean>


or

or(...exprs): Expression<boolean>

exprs[0] || exprs[1] || ... || exprs[n]

Parameters

NameType
...exprsExpressionOrValue<boolean>[]

Returns

Expression<boolean>


not

not(x): Expression<boolean>

!x

Parameters

NameType
xExpressionOrValue<boolean>

Returns

Expression<boolean>


field

field<FieldPath>(fieldPath): Expression<FieldTypeFromFieldPath<DocumentByInfo<TableInfo>, FieldPath>>

Evaluates to the field at the given fieldPath.

For example, in filter this can be used to examine the values being filtered.

Example

On this object:

{
"user": {
"isActive": true
}
}

field("user.isActive") evaluates to true.

Type parameters

NameType
FieldPathextends string

Parameters

NameType
fieldPathFieldPath

Returns

Expression<FieldTypeFromFieldPath<DocumentByInfo<TableInfo>, FieldPath>>