Skip to content

Class: FilterBuilder

The FilterBuilder is an API for building OData Filter options.

Hierarchy

  • BaseDataBuilder

  • FilterBuilder

Implements

  • IBuilder
  • IDebuggable

Summary

Constructors

Properties

Class Properties

Inherited Properties

Accessors

Class Accessors

Inherited Accessors

Methods

Class Methods

Inherited Methods

Constructors

constructor

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

Overrides void

Parameters:

Name Type
context IContext
...terms FilterBuilder[] | string[]

Returns: FilterBuilder

Properties

Accessors

debugString

getter

Returns: string


terms

getter

Returns: IFilterTerm[]

Methods

and

and(...terms: FilterBuilder[] | string[]): 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);

This API take a varying number arguments of either FilterBuilder or string.

Parameters:

Name Type Description
...terms FilterBuilder[] | string[] a comma-separated list of FilterBuilder or string.

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: FilterBuilder[] | string[]): 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);

This API take a varying number arguments of FilterBuilder or string.

Parameters:

Name Type Description
...terms FilterBuilder[] | string[] a comma-separated list of FilterBuilder or string.

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: FilterBuilder[] | string[]): 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);

This API take a varying number arguments of FilterBuilder or string.

Parameters:

Name Type Description
...terms FilterBuilder[] | string[] a comma-separated list of FilterBuilder or string.

Returns: this

return a FilterBuilder instance for chaining