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

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

Properties

Accessors

debugString

get debugString(): string

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

get expandOption(): string[]

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 filterOption(): FilterBuilder

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.


hasExpand

get hasExpand(): boolean

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 hasFilter(): boolean

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 hasMDKSearch(): boolean

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

Example:

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

Returns: boolean

true if it has MDK serach options


hasOrderBy

get hasOrderBy(): boolean

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


hasSelect

get hasSelect(): boolean

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 hasSkip(): boolean

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 hasSkipToken(): boolean

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 hasTop(): boolean

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 orderByOption(): string[]

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 originalQueryOptions(): Object

Return the original query options

Returns: Object


selectOption

get selectOption(): string[]

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

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 skipTokenOption(): string

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

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 userFilter(): string

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 userOrderBy(): string

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

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: FilterTerm[]): 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'");

Parameters:

Name Type Description
...terms FilterTerm[] variadic arguments specified as comma-separated FilterTerms. The parameters to this API can be either a FilterBuilder or a string. This combinations is known as a FilterTerm.

Returns: FilterBuilder

a FilterBuilder instance.


filterTerm

filterTerm(...terms: FilterTerm[]): 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 FilterTerm[] variadic arguments specified as comma-separated FilterTerms

Returns: FilterBuilder

a FilterBuilder instance.


mdkSearch

mdkSearch(searchString: string): MDKSearchBuilder

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: MDKSearchBuilder

returns a MDKSearchBuilder instance


orderBy

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

Parameters:

Name Type
...orderByOptions string[]

Returns: this


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:

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

Expand

Expand: string = "expand"

Filter

Filter: string = "filter"

OrderBy

OrderBy: string = "orderby"

Select

Select: string = "select"

Skip

Skip: string = "skip"

Top

Top: string = "top"