ReQL Query Object Notation

ReQON ([ɹiːˈkʰɑn], /riːˈkɑn/, RE-kon) lets you build simple, read-only ReQL queries from a JSON data structure.

Contents:

Query descriptor

The ReQON query descriptor is an object with specific attributes:

{
    '$db': 'imdb',
    '$table': 'movies',
    '$query': [],
}

$db

References a specific database.

ReQON ReQL
{'$db': 'imdb'} r.db('imdb')

This attribute is optional.

$table

Return all of the documents in the specified table of the default database.

ReQON ReQL
{'$table': 'movies'} r.table('movies')
{'$db': 'imdb', '$table': 'movies'} r.db('imdb').table('movies')

This attribute is required.

$query

The query attribute is a sequence of terms that filter, manipulate, or aggregate the document sequence in some way. Each term in the sequence is a list of 1 or 2 items, where the first item is the name of the term, followed (optionally, depending on the term) by a list of arguments.

This attribute is optional; omitting this attribute is the same as fetching every document in the specified $table.

Terms

Selecting data

$get

get(key)

See also: http://rethinkdb.com/api/python/get/

$get_all

get_all(keys[, index])

See also: http://rethinkdb.com/api/python/get_all/

$filter

filter(predicate)
Boolean operator ReQL See also:
$and r.and_ http://rethinkdb.com/api/python/and/
$or r.or_ http://rethinkdb.com/api/python/or/
$not r.not_ http://rethinkdb.com/api/python/not/

See also: http://rethinkdb.com/api/python/filter/

$between

between(lower_key, upper_key[, index, left_bound, right_bound])

Transformations

$has_fields

has_fields(fields)

See also: http://rethinkdb.com/api/python/has_fields/

$with_fields

with_fields(fields)

See also: http://rethinkdb.com/api/python/with_fields/

$order_by

order_by(key | index[, ordering])

See also: http://rethinkdb.com/api/python/order_by/

$limit

limit(n)

See also: http://rethinkdb.com/api/python/limit/

$slice

slice(start_offset[, end_offset, left_bound, right_bound])

See also: http://rethinkdb.com/api/python/slice/

$sample

sample(n)

See also: http://rethinkdb.com/api/python/sample/

Manipulation

$pluck

pluck(fields)

See also: http://rethinkdb.com/api/python/pluck/

$without

without(fields)

See also: http://rethinkdb.com/api/python/without/

Aggregation

$group

group(field | index[, multi])

See also: http://rethinkdb.com/api/python/group/

$count

count()

See also: http://rethinkdb.com/api/python/count/

$sum

sum(field)

See also: http://rethinkdb.com/api/python/sum/

$avg

avg(field)

See also: http://rethinkdb.com/api/python/avg/

$min

min(field)

See also: http://rethinkdb.com/api/python/min/

$max

max(field)

See also: http://rethinkdb.com/api/python/max/

Geospatial

$get_intersecting

get_intersecting(geometry, index)

See also: http://rethinkdb.com/api/python/get_intersecting/

$get_nearest

get_nearest(geometry, index[, max_results, max_dist, unit, geo_system])

See also: http://rethinkdb.com/api/python/get_nearest/

Selecting data

Term Description
$get Get a single document by its primary key
$get_all Get all documents where the given value matches the requested index
$filter Get all the documents for which the specified sequence is true

Transformations

Term Description
$with_fields Exclude documents that do not have the specified fields and return only those fields
$has_fields Test if a document has the specified fields, filtering out any that do not
$order_by Sort the documents by the specified field or index
$skip Skip a number of documents from the head of the sequence
$limit End the sequence after the givin number of documents
$slice Return the documents within the specified range
$nth Get the nth document in the sequence
$sample Select a given number of elements from a sequence with uniform random distribution

Manipulation

Term Description
$pluck Return only the specified fields
$without The opposite of $pluck, return the documents without the specified fields

Aggregation

Term Description
$group Partition the documents into multiple groups based on the specified field
$count Count the number of documents in the sequence
$sum Sum the specified field of the sequence
$avg Average the specified field of the sequence
$min Find the minimum value of the specified field in the sequence
$max Find the maximum value of the specified field of the sequence

Geospatial

Term Description
$get_intersecting Get all documents where the given geometry object intersects with a geometry object of a geospatial index
$get_nearest Return the documents closest to the specified point based on a geospatial index

Indices and tables