Query
Query provides functionality to build a query that can be used against a data store.
Methods
addParam
Add additional parameters that will be sent with the remote requests.
Parameter | Type | Description |
---|---|---|
key | String | Specifies the key for the additional parameter. |
value | String Function | Specifies the value of the additional parameter for the key or a function to return a value. |
Returns: Query
aggregate
Specifies an aggregate for the given field.
Parameter | Type | Description |
---|---|---|
key | String | Specifies the aggregate type, for example: sum, avg, min, max. |
value | String | Specifies the field to apply the aggregate on. |
Returns: Query
clone
Creates a copy of the current query object.
Returns: Query
execute
Execute the given query against the data store.
Parameter | Type | Description |
---|---|---|
success (optional) | Function | Specifies the callback function invoked on a success. |
fail (optional) | Function | Specifies the callback function invoked on a failure. |
always (optional) | Function | Specifies the callback function invoked for either a success or failure. |
Returns: Query
executeLocal
Execute the given query against local data.
Parameter | Type | Description |
---|---|---|
success (optional) | Function | Specifies the callback function invoked on a success. |
fail (optional) | Function | Specifies the callback function invoked on a failure. |
always (optional) | Function | Specifies the callback function invoked for either a success or failure. |
Returns: Query
expand
Call to expand a related table.
Parameter | Type | Description |
---|---|---|
tableNames | String Object[] | Specifies the related tables to expand. |
Returns: Query
form
Specifies the name of table to retrieve data in query execution.
Parameter | Type | Description |
---|---|---|
tableName | String String[] | Specifies the table name to execute the query on. |
Returns: Query
group
Group the data using the specified field.
Parameter | Type | Description |
---|---|---|
fieldName | String | Specifies the field that will be grouped. |
comparer (optional) | Function | Specifies a custom function to group the data. |
format (optional) | String | Specifies the group format. |
Returns: Query
page
Specifies the paging index and size to be used to retrieve data.
Parameter | Type | Description |
---|---|---|
pageIndex | Number | Specifies the start index of the data. |
pageSize | Number | Specifies the end index of the data. |
Returns: Query
range
Specifies a start and end index to with data is returned.
Parameter | Type | Description |
---|---|---|
start | Number | Specifies the start index of the data. |
end | Number | Specifies the end index of the data. |
Returns: Query
requireCount
Specifies whether to return the total number of records returned from the data store.
Returns: Query
search
Execute a search with the data using the specified search criteria.
Parameter | Type | Description |
---|---|---|
value | String Number Boolean | Specifies the value to search for. |
fieldNames (optional) | Number String[] | Specifies the field or a collection of field names to search. |
operator (optional) | String Operator | Specifies the operator to use when searching. |
ignoreCase (optional) | Boolean | When true, ignores character casing when comparing characters. |
ignoreAccent (optional) | Boolean | When true, ignores accent and will normalize certain characters. |
Returns: Query
select
Specifies the columns to be returned from the data store.
Parameter | Type | Description |
---|---|---|
fields | String String[] | Specifies the select columns. |
Returns: Query
setDataStore
Sets the data store to be used when executing the query.
Parameter | Type | Description |
---|---|---|
dataStore | DataStore | Specifies the data store to be used when executing the query. |
Returns: Query
setKey
Sets the primary key field.
Parameter | Type | Description |
---|---|---|
field | String | Specifies the field/column to be used as the primary key. |
Returns: Query
skip
Specifies how many records will be skipped from the top of the data.
Parameter | Type | Description |
---|---|---|
rows | Number | Specifies the number of records to skip. |
Returns: Query
sortBy
Specifies the field name to be used in sorting the results. Default sort in ascending order.
Parameter | Type | Description |
---|---|---|
fieldName | String | Specifies a field or collection of fields to sort the data on. |
comparer (optional) | Function | Define the sort direction or sort comparer function to provided custom sorting. |
Returns: Query
take
Specifies how many records will be returned from the top of the data.
Parameter | Type | Description |
---|---|---|
rows | Number | Specifies the number of records to return. |
Returns: Query
where
Specifies the filter criteria for the query.
Parameter | Type | Description |
---|---|---|
fieldName | String Predicate | Specifies the field name (left side) to be used in the filter or a predicate to filter on. |
operator (optional) | String Operator | Specifies the filter operator. |
value (optional) | Object | Specifies the value (right side) of the filter. |
ignoreCase (optional) | Boolean | When true, ignores character casing when comparing characters. |
ignoreAccent (optional) | Boolean | When true, ignores accent and will normalize certain characters. |
Returns: Query