sort

Sorting documents

To sort the documents (or files) embedded in a collection (or bucket) representation, use the sort_by query parameter.

Default sorting is by _id descending. If _id are ObjectId, this makes sure that last created document or file is the first returned.

Examples:

sort by the property date ascending

$ http GET 127.0.0.1:8080/test/coll?sort_by=date

sort by the property date descending

$ http GET 127.0.0.1:8080/test/coll?sort_by=-date

sort by the property date descending and title ascending

http GET 127.0.0.1:8080/test/coll?sort_by=-date&sort_by=title

note that you specify multiple sort options using multiple sort_by query parameters

Documentation references

How to use the examples

The examples make use of the brilliant httpie CLI HTTP client and are ment to be used with RESTHeart stareted on the localhost without the authentication enabled.

Eventually pass username and password with the -a username:password option.