Skip to content

Class: FilterBuilder

The FilterBuilder is an API for building OData Filter options.

Hierarchy

  • BaseDataBuilder

  • FilterBuilder

Implements

  • IBuilder
  • IDebuggable

Summary

Constructors

Properties

Accessors

Methods

Constructors

constructor

+ new FilterBuilder(context: IContext, ...terms: FilterTerm[]): FilterBuilder

Overrides void

Parameters:

Name Type
context IContext
...terms FilterTerm[]

Returns: FilterBuilder

Properties

Protected _context

_context: IContext

Inherited from void


Protected _data

_data: any

Inherited from void


Protected _excludedTypes

_excludedTypes: [ValueType]

Inherited from void

Accessors

data

get data(): any

Inherited from void

Returns: any


debugString

get debugString(): string

Returns: string


Protected doNotResolveKeys

set doNotResolveKeys(doNotResolve: object): void

Inherited from void

Parameters:

Name Type
doNotResolve object

Returns: void


Protected excludedTypes

set excludedTypes(types: [ValueType]): void

Inherited from void

Parameters:

Name Type
types [ValueType]

Returns: void


terms

get terms(): IFilterTerm[]

Returns: IFilterTerm[]

Methods

and

and(...terms: FilterTerm[]): this

The OData and operator is added to the filter option by invoking the FilterBuilder and API.

Exmalpe:

filterBuilder.and("PriorityType eq 'PM'");
or
const filterTerm = new FilterBuilder({}, "PriorityType eq 'PM'");
filterBuilder.and(filterTerm);

Parameters:

Name Type Description
...terms FilterTerm[] variadic arguments specified as comma-separated FilterTerms

Returns: this

return a FilterBuilder instance for chaining


build

build(): Promise‹any›

Overrides void

Asynchronously build the filter based on all added FilterItems

Returns: Promise‹any›

return a Promise wirth filter string


Protected createFilterTerm

createFilterTerm(term: any): string

Create the filter string for a specific FilterItem

Parameters:

Name Type Description
term any the filter item

Returns: string

return a filter string


equal

equal(property: string, rhs: any): this

The OData eq operator is added to the filter option by invoking the FilterBuilder equal API.

Exmalpe:

filterBuilder.equal("PriorityType", "PM");

Parameters:

Name Type Description
property string the property name
rhs any the right hand side of 'eq' operator (value)

Returns: this

return a FilterBuilder instance for chaining


greaterThan

greaterThan(property: string, rhs: any): this

The OData gt operator is added to the filter option by invoking the FilterBuilder greaterThan API.

Exmalpe:

filterBuilder.greaterThan("OrderID", "100043");

Parameters:

Name Type Description
property string the property name
rhs any the right hand side of 'gt' operator (value)

Returns: this

return a FilterBuilder instance for chaining


lessThan

lessThan(property: string, rhs: any): this

The OData lt operator is added to the filter option by invoking the FilterBuilder greaterThan API.

Exmalpe:

filterBuilder.lessThan("OrderID", "100043");

Parameters:

Name Type Description
property string the property name
rhs any the right hand side of 'lt' operator (value)

Returns: this

return a FilterBuilder instance for chaining


lessThanOrEqual

lessThanOrEqual(property: string, rhs: any): this

The OData le operator is added to the filter option by invoking the FilterBuilder greaterThan API.

Exmalpe:

filterBuilder.lessThanOrEqual("OrderID", "100043");

Parameters:

Name Type Description
property string the property name
rhs any the right hand side of 'le' operator (value)

Returns: this

return a FilterBuilder instance for chaining


not

not(...terms: FilterTerm[]): this

The OData not operator is added to the filter option by invoking the FilterBuilder and API.

Exmalpe:

filterBuilder.not("PriorityType eq 'PM'");
or
const filterTerm = new FilterBuilder({}, "PriorityType eq 'PM'");
filterBuilder.not(filterTerm);

Parameters:

Name Type Description
...terms FilterTerm[] variadic arguments specified as comma-separated FilterTerms

Returns: this

return a FilterBuilder instance for chaining


notEqual

notEqual(property: string, rhs: any): this

The OData ne operator is added to the filter option by invoking the FilterBuilder equal API.

Exmalpe:

filterBuilder.notEqual("PriorityType", "PM");

Parameters:

Name Type Description
property string the property name
rhs any the right hand side of 'ne' operator (value)

Returns: this

return a FilterBuilder instance for chaining


or

or(...terms: FilterTerm[]): this

The OData or operator is added to the filter option by invoking the FilterBuilder and API.

Exmalpe:

filterBuilder.or("PriorityType eq 'PM'");
or
const filterTerm = new FilterBuilder({}, "PriorityType eq 'PM'");
filterBuilder.or(filterTerm);

Parameters:

Name Type Description
...terms FilterTerm[] variadic arguments specified as comma-separated FilterTerms

Returns: this

return a FilterBuilder instance for chaining