Back to top

ReQL command: get_all

Command syntax

table.get_all([key1, key2...], [, index='id']) → selection


Get all documents where the given value matches the value of the requested index.

Example: Secondary index keys are not guaranteed to be unique so we cannot query via get when using a secondary index.

r.table('marvel').get_all('man_of_steel', index='code_name').run(conn)

Example: Without an index argument, we default to the primary index. While get will either return the document or None when no document with such a primary key value exists, this will return either a one or zero length stream.


Example: You can get multiple documents in a single call to get_all.

r.table('dc').get_all('superman', 'ant man').run(conn)

Note: get_all does not perform any de-duplication. If you pass the same key more than once, the same document will be returned multiple times.

Example: You can use args with get_all to retrieve multiple documents whose keys are in a list. This uses get_all to get a list of female superheroes, coerces that to an array, and then gets a list of villains who have those superheroes as enemies.
    r.table('heroes').get_all('f', index='gender')['id'].coerce_to('array'), 
    lamdba heroines: r.table('villains').get_all(r.args(heroines))

Calling get_all with zero arguments—which could happen in this example if the heroines list had no elements—will return nothing, i.e., a zero length stream.

Secondary indexes can be used in extremely powerful ways with get_all and other commands; read the full article on secondary indexes for examples using boolean operations, contains and more.

Get more help

Couldn't find what you were looking for?