Query
The default structure of objects used to represent queries.
{filter: FILTER, sort: SORT, page: PAGE}
The following is an example query:
{
// Selects only the todos that match.
filter: {
complete: false
},
// Sort the results of the selection
sort: "name desc",
// Selects a range of the sorted result
page: {start: 0, end: 19}
}
Parameters
- filter
{Object}:The
filterproperty is an object of property names to values like:{ filter: { age: {$gt: 21}, name: ["Justin","Ramiya"] } }The Comparison Operators (
$eq,$gt,$gte,$in,$lt,$lte,$ne,$nin) are available withinfilter. - sort
{String}:The
sortproperty is an optional value specifying:- the property used to sort the results of a query, and
- the direction of the sort (start the value with
-for descending).
The sort property is specified as a string like
sort: "age".sort: "age"will return results ascending by theageproperty.sort: "-age"will return results descending by theageproperty.This format follows JSON API's recommendations on sorting. However,
can-query-logiccan only sort by a single property currently.The
sortproperty defaults to"ID_PROPERTY"whereID_PROPERTYis the first identity property returned by identityKeys. This is usually the first identity value on the schema passed tonew QueryLogic():new QueryLogic({ identity: ["_id"] }).identityKeys() //-> ["_id"] - page
{Object}:The optional
pageproperty selects a range of the sorted result. It's values are inclusive and begin at0. This means that:{start: 0, end: 1}- Selects the first two records in the result.{start: 10, end: 19}- Selects 10 records after the first 10 records.
The
startvalue defaults to0and theendvalue defaults toInfinity. This means that:{end: 99}- Selects the first 100 records.{start: 100}- Selects all records after the first 100.