Composite Filters (Reference)
The script content on this page is for navigation purposes only and does not alter the content in any way.
A composite filter specification can appear only at the top level. That is, you cannot nest a composite filter inside another composite filter or inside a filter condition.
A composite filter is an object that has at most one member of each of these clauses:1
-
Query clause
It has the form
$query :filter_condition. -
Orderby clause
It has the form
$orderby :orderby_spec, where is an array or an object specifying the sort order for the selected documents.
The order of the clauses is not significant. Absence of a clause has the same effect as applying its operator to an operand that is an empty object: Absence of a query clause selects all documents; absence of an orderby clause imposes no order.
The following composite filter contains a query clause and an orderby clause. The query clause selects documents that have a salary field whose value is greater than 10,000. The orderby clause sorts the selected documents first by descending age and then by ascending zip code.
{ "$query" : { "salary" : { "gt" : 10000 } },
"$orderby" : { "age" : -1, "zip" : 2 } }
-
Orderby Clause Sorts Selected Objects
A filter specification with an orderby clause returns the selected JSON documents in sorted order.
Related Topics
-
SODA for REST provides additional clauses for use in a composite filter. ↩