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

  • IBuilder
  • IDebuggable

Summary

Constructors

Properties

Class Properties

Currently none in this class.

Inherited Properties

Accessors

Class Accessors

Inherited Accessors

Methods

Class Methods

Inherited Methods

Object literals

Class Object literals

Inherited Object literals

Constructors

constructor

+ new DataQueryBuilder(context: IContext, queryOptions: string): DataQueryBuilder

Overrides void

Parameters:

Name Type Default
context IContext -
queryOptions string ""

Returns: DataQueryBuilder

Accessors

applyOption

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

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


expandOption

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

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

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

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

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

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

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

getter

Returns: boolean


hasSelect

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

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

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

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

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

getter

Return the original query options

Returns: Object


searchOption

getter

Returns: SearchBuilder


selectOption

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

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

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

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

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

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.

example

dataQueryBuilder.apply("groupby((Property))");

Parameters:

Name Type
apply string

Returns: this

current DataQueryBuilder instance. It could be chained with other operators


build

build(): Promise‹any›

Overrides void

Asynchronously build the data query

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.

example

dataQueryBuilder.expand('EntitySet1', 'EntitySet2');

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

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

This method breaks DataQueryBuilder instance method chaining.

example

dataQueryBuilder.filter("Priority eq '2'");

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

Parameters:

Name Type Description
...terms QueryOptionBuilder[] | string[] 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(...terms: QueryOptionBuilder[] | string[]): SearchBuilder

Parameters:

Name Type
...terms QueryOptionBuilder[] | string[]

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.

example

dataQueryBuilder.select('Property1');

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: number | string): 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

example

dataQueryBuilder.skip(2);

Parameters:

Name Type
skip number | string

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

example

dataQueryBuilder.skipToken('skiptoken=sdo6yu5cvep602ff4vkw3fzuklp2zrvzrvbl6');

Parameters:

Name Type
skipToken string

Returns: this

current DataQueryBuilder instance. It could be chained with other operators


top

top(top: number | string): 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.

example

dataQueryBuilder.top(50);
// For Chaining, you could do as follows
dataQueryBuilder.top(50).skip(5);

Parameters:

Name Type
top number | string

Returns: this

current DataQueryBuilder instance. It could be chained with other operators

Object literals

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

Search: string = "search"

Select

Select: string = "select"

Skip

Skip: string = "skip"

Top

Top: string = "top"