Skip to content

Class: DataQueryBuilder

The DataQueryBuilder is an API for building OData Query Options.

  • Unless specified, the DataQueryBuilder API methods return the DataQueryBuilder instance which provides an easy mechanism to chain multiple API invocations.
  • Unless specified, the DataQueryBuilder API methods implement a variadic argument interface where multiple arguments are specified using comma-separated strings.

Hierarchy

  • BaseDataBuilder

  • DataQueryBuilder

Implements

  • IDebuggable

Summary

Constructors

Properties

Class Properties

Inherited Properties

Currently none inherited from the parent class(es).

Accessors

Class Accessors

Inherited Accessors

Currently none inherited from the parent class(es).

Methods

Class Methods

Inherited Methods

Currently none inherited from the parent class(es).

Constructors

Constructor

+ new DataQueryBuilder(context: IContext, queryOptions?: string = ''): DataQueryBuilder

Overrides BaseDataBuilder.constructor

Parameters:

Name Type
context IContext
queryOptions? string = ''

Returns: DataQueryBuilder

Properties

Static systemQueryOptions

systemQueryOptions: object

Available system query options

Apply

Apply: string = 'apply'

Expand

Expand: string = 'expand'

Filter

Filter: string = 'filter'

OrderBy

OrderBy: string = 'orderby'

Search: string = 'search'

Select

Select: string = 'select'

Skip

Skip: string = 'skip'

Top

Top: string = 'top'

Accessors

applyOption

Get Signature

getter

Returns the value of the apply options.

Example
dataQueryBuilder.apply("groupby((Property))");
dataQueryBuilder.applyOption === "groupby((Property))";
Returns

string

the value of the apply options as string if specified.


debugString

Get Signature

getter

This API returns a string representation of the current builder state without doing any building.

Example
console.log(dataQueryBuilder.debugString);

// The result will be something like
- EXPAND:  Operations, Equipment
- ORDERBY: OrderId
- SELECT:  -
- TOP:     -
- SKIP:    -
- FILTER:  (OrderType eq 'PM02' and (Priority eq '3' or MDKSearch("Low")))
Returns

string

the current string representation of the current builder

Implementation of IDebuggable.debugString


expandOption

Get Signature

getter

Returns the value of the expand options.

Example
dataQueryBuilder.expand('EntitySet1');
dataQueryBuilder.expandOption[0] === 'EntitySet1';
Returns

string[]

the value of the expand options if specified.


filterOption

Get Signature

getter

Returns the current filterBuilder for the DataQueryBuilder instance

Example
dataQueryBuilder.filter("Priority eq '2'");
const filterBuilder = dataQueryBuilder.filterOption;
Returns

FilterBuilder

the current filterBuilder for the DataQueryBuilder instance if specified.


hasApply

Get Signature

getter

This value is to check if the data query builder has apply options.

Example
dataQueryBuilder.apply('groupby((Property))');
dataQueryBuilder.hasApply === true;
Returns

boolean

true if it has apply options


hasExpand

Get Signature

getter

This value is to check if the data query builder has expend options.

Example
dataQueryBuilder.expand('EntitySet1');
dataQueryBuilder.hasExpand === true;
Returns

boolean

true if it has expend options


hasFilter

Get Signature

getter

This value is to check if the data query builder has filter options.

Example
dataQueryBuilder.filter("Priority eq '2'");
dataQueryBuilder.hasFilter === true;
Returns

boolean

true if it has filter options


hasMDKSearch

Get Signature

getter

This value is to check if the data query builder has MDK search options.

Example
dataQueryBuilder.mdkSearch("Priority eq '2'");
dataQueryBuilder.hasMDKSearch === true;
Returns

boolean

true if it has MDK search options


hasOrderBy

Get Signature

getter

This value is to check if the data query builder has orderBy options.

Example
dataQueryBuilder.orderBy("Property1");
dataQueryBuilder.hasOrderBy === true;
Returns

boolean

true if it has orderBy options


hasSearch

Get Signature

getter

Returns

boolean


hasSelect

Get Signature

getter

This value is to check if the data query builder has select options.

Example
dataQueryBuilder.select("Property1");
dataQueryBuilder.hasSelect === true;
Returns

boolean

true if it has select options


hasSkip

Get Signature

getter

This value is to check if the data query builder has skip options.

Example
dataQueryBuilder.skip(2);
dataQueryBuilder.hasSkip === true;
Returns

boolean

true if it has skip options


hasSkipToken

Get Signature

getter

This value is to check if the data query builder has skipToken option.

Example
dataQueryBuilder.skipToken('skiptoken=sdo6yu5cvep602ff4vkw3fzuklp2zrvzrvbl6');
dataQueryBuilder.hasSkipToken === true;
Returns

boolean

true if it has skipToken option


hasTop

Get Signature

getter

This value is to check if the data query builder has top options.

Example
dataQueryBuilder.top(5);
dataQueryBuilder.hasTop === true;
Returns

boolean

true if it has top options


orderByOption

Get Signature

getter

Returns the value of the orderBy options.

Example
dataQueryBuilder.orderBy('Property1');
dataQueryBuilder.orderByOption[0] === 'Property1';
Returns

string[]

the value of the orderBy options if specified.


originalQueryOptions

Get Signature

getter

Return the original query options

Returns

Object


searchOption

Get Signature

getter

Returns

SearchBuilder


selectOption

Get Signature

getter

Returns the value of the select options.

Example
dataQueryBuilder.select('Property1');
dataQueryBuilder.selectOption[0] === 'Property1';
Returns

string[]

the value of the select options if specified.


skipOption

Get Signature

getter

Returns the value of the skip options.

Example
dataQueryBuilder.skip(2);
dataQueryBuilder.skipOption === 2;
Returns

string | number

the value of the skip options as number or string if specified.


skipTokenOption

Get Signature

getter

Returns the value of skipToken option.

Example
dataQueryBuilder.skipToken('skiptoken=sdo6yu5cvep602ff4vkw3fzuklp2zrvzrvbl6');
dataQueryBuilder.skipTokenOption === 'skiptoken=sdo6yu5cvep602ff4vkw3fzuklp2zrvzrvbl6';
Returns

string

the value of skipToken option as a string.


topOption

Get Signature

getter

Returns the value of the top options.

Example
dataQueryBuilder.top(5);
dataQueryBuilder.topOption === 5;
Returns

string | number

the value of the top options as number or string if specified.


userFilter

Get Signature

getter

This value is the current filter selected by you from the filter dialog. This is a grouped query option separated with an 'or' operator.

Example
const userFilter = dataQueryBuilder.userFilter;
userFilter === "(Priority eq '1' or Priority eq '3')"
Returns

string

the current filter if specified or empty string.


userOrderBy

Get Signature

getter

This value is the current ordering selected by you from the filter dialog.

Example
const userOrderBy = dataQueryBuilder.userOrderBy;
userOrderBy === "OrderId"
Returns

string

the current ordering if specified or empty string.

Methods

apply

apply(apply: string): this

The OData apply option is specified by invoking the DataQueryBuilder apply API. This non-variadic method accepts a single string representing the apply system option.

Parameters:

Name Type
apply string

Returns: this

current DataQueryBuilder instance. It could be chained with other operators


build

build(): Promise<any>

Asynchronously build the data query

Overrides BaseDataBuilder.build

Returns: Promise<any>

Promise with the query string as result


expand

expand(...expandOptions: ...string[]): this

The OData expand options are addedd to the query by invoking the DataQueryBuilder expand API. This variadic method accepts a comma-separated list of strings representing the expand system options.

Parameters:

Name Type Description
expandOptions ...string[] a comma-separated list of strings

Returns: this

current DataQueryBuilder instance. It could be chained with other operators


filter

filter(...terms: string[] | QueryOptionBuilder[]): FilterBuilder

This API method creates a FilterBuilder and adds it to the current DataQueryBuilder instance.

This method breaks DataQueryBuilder instance method chaining.

Parameters:

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

Returns: FilterBuilder

a FilterBuilder instance.


filterTerm

filterTerm(...terms: FilterBuilder[] | string[]): FilterBuilder

This API method creates a FilterBuilder without adding it to the current DataQueryBuilder instance. Use the API to construct a filter statement isolated from the DataQueryBuilder and add once the filter terms are complete using the FilterBuilder APIs

This method breaks DataQueryBuilder instance method chaining.

Parameters:

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

Returns: FilterBuilder

a FilterBuilder instance.


mdkSearch

mdkSearch(searchString: string): QueryOptionBuilder

This API method created a FilterBuilder that will contain the Filter Term to execute the MDK automatic search for a given string. That is the properties that are directly bound in the table or using dynamic target paths will be searched on my MDK.

The filter builder will not be added to the current DataQueryBuilder instance. The caller is responsible for that in order to place it in the right position with the other search terms.

Parameters:

Name Type Description
searchString string seaerch string

Returns: QueryOptionBuilder

returns a MDKSearchBuilder instance


orderBy

orderBy(...orderByOptions: ...string[]): this

Parameters:

Name Type
orderByOptions ...string[]

Returns: this


search

search(...terms: string[] | QueryOptionBuilder[]): SearchBuilder

Parameters:

Name Type
terms string[] | QueryOptionBuilder[]

Returns: SearchBuilder


select

select(...selectOptions: ...string[]): this

The OData select options are addedd to the query by invoking the DataQueryBuilder select API. This variadic method accepts a comma-separated list of strings representing the select system options.

Parameters:

Name Type Description
selectOptions ...string[] variadic arguments specified as comma-separated strings

Returns: this

current DataQueryBuilder instance. It could be chained with other operators


skip

skip(skip: string | number): this

The OData skip option is specified by invoking the DataQueryBuilder skip API. This non-variadic method accepts a single string or number representing the skip system option

Parameters:

Name Type
skip string | number

Returns: this

current DataQueryBuilder instance. It could be chained with other operators


skipToken

skipToken(skipToken: string): this

The OData skiptoken option is specified by invoking the DataQueryBuilder skipToken API. This non-variadic method accepts a single string representing the skiptoken system option

Parameters:

Name Type
skipToken string

Returns: this

current DataQueryBuilder instance. It could be chained with other operators


top

top(top: string | number): this

The OData top option is specified by invoking the DataQueryBuilder top API. This non-variadic method accepts a single string or number representing the top system option.

Parameters:

Name Type
top string | number

Returns: this

current DataQueryBuilder instance. It could be chained with other operators