Getting Started with RethinkDB by Gianluca Tiepolo

Getting Started with RethinkDB by Gianluca Tiepolo

Author:Gianluca Tiepolo [Tiepolo, Gianluca]
Language: eng
Format: azw3
Publisher: Packt Publishing
Published: 2016-03-17T04:00:00+00:00


Sorting documents

The ReQL query language provides the orderBy command to sort documents. This command accepts the name of a field or index that can be used to sort as the input.

Sorting direction can be r.asc (ascending) or r.desc (descending). For example, to sort documents based on the age field in the ascending order, run the following query:

r.db("test").table("people").orderBy('age')

Let's look at another example. This time, let's sort the documents alphabetically based on the surname in the descending order, limiting the results to the first 10 documents and skipping the first five results:

r.db("test").table("people").orderBy(r.desc('surname')).skip(5).limit(10)



Download



Copyright Disclaimer:
This site does not store any files on its server. We only index and link to content provided by other sites. Please contact the content providers to delete copyright contents if any and email us, we'll remove relevant links or contents immediately.