Page Contents
Home > @loopback/filter > WhereBuilder
WhereBuilder class
A builder for Where object. It provides fluent APIs to add clauses such as and, or, and other operators.
Signature:
export declare class WhereBuilder<MT extends object = AnyObject>
Example
const whereBuilder = new WhereBuilder();
const where = whereBuilder
.eq('a', 1)
.and({x: 'x'}, {y: {gt: 1}})
.and({b: 'b'}, {c: {lt: 1}})
.or({d: 'd'}, {e: {neq: 1}})
.build();
Constructors
| Constructor | Modifiers | Description |
|---|---|---|
| [(constructor)(w)](/doc/en/lb4/apidocs.filter.wherebuilder._constructor_.html) | Constructs a new instance of the `WhereBuilder` class |
Properties
| Property | Modifiers | Type | Description |
|---|---|---|---|
| [where](/doc/en/lb4/apidocs.filter.wherebuilder.where.html) | [Where](/doc/en/lb4/apidocs.filter.where.html)<MT> |
Methods
| Method | Modifiers | Description |
|---|---|---|
| [and(w)](/doc/en/lb4/apidocs.filter.wherebuilder.and.html) | Add an `and` clause. | |
| [between(key, val1, val2)](/doc/en/lb4/apidocs.filter.wherebuilder.between.html) | Add a `between` condition | |
| [build()](/doc/en/lb4/apidocs.filter.wherebuilder.build.html) | Get the where object | |
| [cast(clause)](/doc/en/lb4/apidocs.filter.wherebuilder.cast.html) | ||
| [eq(key, val)](/doc/en/lb4/apidocs.filter.wherebuilder.eq.html) | Add an `=` condition | |
| [exists(key, val)](/doc/en/lb4/apidocs.filter.wherebuilder.exists.html) | Add a `exists` condition | |
| [gt(key, val)](/doc/en/lb4/apidocs.filter.wherebuilder.gt.html) | Add a `>` condition | |
| [gte(key, val)](/doc/en/lb4/apidocs.filter.wherebuilder.gte.html) | Add a `>=` condition | |
| [ilike(key, val)](/doc/en/lb4/apidocs.filter.wherebuilder.ilike.html) | Add a `ilike` condition | |
| [impose(where)](/doc/en/lb4/apidocs.filter.wherebuilder.impose.html) | Add a where object. For conflicting keys with the existing where object, create an `and` clause. | |
| [inq(key, val)](/doc/en/lb4/apidocs.filter.wherebuilder.inq.html) | Add a `inq` condition | |
| [like(key, val)](/doc/en/lb4/apidocs.filter.wherebuilder.like.html) | Add a `like` condition | |
| [lt(key, val)](/doc/en/lb4/apidocs.filter.wherebuilder.lt.html) | Add a `<` condition | |
| [lte(key, val)](/doc/en/lb4/apidocs.filter.wherebuilder.lte.html) | Add a `<=` condition | |
| [neq(key, val)](/doc/en/lb4/apidocs.filter.wherebuilder.neq.html) | Add a `!=` condition | |
| [nilike(key, val)](/doc/en/lb4/apidocs.filter.wherebuilder.nilike.html) | Add a `nilike` condition | |
| [nin(key, val)](/doc/en/lb4/apidocs.filter.wherebuilder.nin.html) | Add a `nin` condition | |
| [nlike(key, val)](/doc/en/lb4/apidocs.filter.wherebuilder.nlike.html) | Add a `nlike` condition | |
| [or(w)](/doc/en/lb4/apidocs.filter.wherebuilder.or.html) | Add an `or` clause. | |
| [regexp(key, val)](/doc/en/lb4/apidocs.filter.wherebuilder.regexp.html) | Add a `regexp` condition |