Page Contents

Home > @loopback/repository > WhereBuilder

WhereBuilder class

A builder for Where object. It provides fluent APIs to add clauses such as and, or, and other operators.


export declare class WhereBuilder<MT extends object = AnyObject> 


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}})


Constructor Modifiers Description
(constructor)(w)   Constructs a new instance of the WhereBuilder class


Property Modifiers Type Description
where   Where<MT>  


Method Modifiers Description
and(w)   Add an and clause.
between(key, val1, val2)   Add a between condition
build()   Get the where object
eq(key, val)   Add an = condition
exists(key, val)   Add a exists condition
gt(key, val)   Add a > condition
gte(key, val)   Add a >= condition
ilike(key, val)   Add a ilike condition
impose(where)   Add a where object. For conflicting keys with the existing where object, create an and clause.
inq(key, val)   Add a inq condition
like(key, val)   Add a like condition
lt(key, val)   Add a < condition
lte(key, val)   Add a <= condition
neq(key, val)   Add a != condition
nilike(key, val)   Add a nilike condition
nin(key, val)   Add a nin condition
nlike(key, val)   Add a nlike condition
or(w)   Add an or clause.
regexp(key, val)   Add a regexp condition