QueryBuilder Class
Query builder class.
Item Index
Methods
_getWhereQueryFilter
-
whereFilters
Return the where filters formatted for the final OData query url.
Parameters:
-
whereFilters
ArrayA list of all the query filters.
Returns:
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
StringUnique id for a filter.
-
filterType
StringThe property filter name(STRING, TIME, DECIMAL, etc).
-
propNames
Array | StringA list of property names.
-
filterOperator
StringThe type of filter(EQUALS, CONTAINS, etc).
-
propValues
Array | StringThe 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:
The filter URL.
generateQueryUrl
()
String
Return the final OData query URL.
Returns:
A fully qualified query URL.
getBaseUrl
()
String
Return the base endpoint url.
Returns:
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
StringThe 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
StringThe property to order by.
-
val
NumberThe 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
NumberThe 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
NumberThe top value.