API Docs for:
Show:

QueryBuilder Class

Module: OData

Query builder class.

Methods

_getWhereQueryFilter

(
  • whereFilters
)
Array private

Return the where filters formatted for the final OData query url.

Parameters:

  • whereFilters Array

    A list of all the query filters.

Returns:

Array:

The where filters formatted for the final OData query url.

addWhereFilter

(
  • id
  • filterType
  • propNames
  • filterOperator
  • propValues
)

Add a filter to the list of filter that are used to build a query string. If you call this method multiple times, each filter is AND'ed together. If propNames or propValues is an array of values, the resulting query string is OR'ed together for that specific filter.

Parameters:

  • id String

    Unique id for a filter.

  • filterType String

    The property filter name(STRING, TIME, DECIMAL, etc).

  • propNames Array | String

    A list of property names.

  • filterOperator String

    The type of filter(EQUALS, CONTAINS, etc).

  • propValues Array | String

    The value for the filter.

Example:

addWhereFilter(OData.STRING, 'FNAME', OData.EQUALS, 'bob') addWhereFilter(OData.STRING, 'LNAME', OData.EQUALS, 'smith') getODataQueryUrl() would return "/api/user/?$filter=FNAME eq 'bob' and LNAME eq 'smith'"

addWhereFilter(OData.STRING, ['FNAME','LNAME'], OData.EQUALS, ['bob','smith']) getODataQueryUrl() would return "/api/user/?$filter=FNAME eq 'bob' or LNAME eq 'smith'"

addWhereFilter(OData.STRING, ['FNAME','LNAME'], OData.EQUALS, 'bob') getODataQueryUrl() would return "/api/user/?$filter=FNAME eq 'bob' or LNAME eq 'bob'"

addWhereFilter(OData.STRING, 'FNAME', OData.EQUALS, ['bob','sam']) getODataQueryUrl() would return "/api/user/?$filter=FNAME eq 'bob' or FNAME eq 'sam'"

generateQueryFilterUrl

() String

Return the filter portion of the OData query URL.

Returns:

String:

The filter URL.

generateQueryUrl

() String

Return the final OData query URL.

Returns:

String:

A fully qualified query URL.

getBaseUrl

() String

Return the base endpoint url.

Returns:

String:

The base endpoint url.

removeAllWhereFilters

()

Clear the filter list for the OData final query url.

removeWhereFilter

(
  • id
)

Delete a specific filter in the filter list.

Parameters:

  • id String

    The id of the filter to remove.

setOrderBy

(
  • propName
  • val
)

Set the $orderby value in the final query. You need to pass the name of the property you want to sort by, and the order of the sort. Valid values are 0, 1, or 2 (NONE, ASC, and DESC respectively). If you pass null, $orderby will be removed from the final query string.

Parameters:

  • propName String

    The property to order by.

  • val Number

    The sort order.

setSkip

(
  • val
)

Set the $skip value in the final query. If you set val to null, $skip will be removed from the final query string.

Parameters:

  • val Number

    The skip value.

setTop

(
  • val
)

Set the $top value in the final query. If you set val to null, $top will be removed from the final query string.

Parameters:

  • val Number

    The top value.