table.getAll([key, key2...]) → 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.
Example: Without an index argument, we default to the primary index. While
get will either return the document or
null 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
r.table("dc").getAll("superman", "ant man").run(conn);
getAll 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
getAll to retrieve multiple documents whose keys are in a list. This uses
getAll 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.do( r.table("heroes").getAll("f").optArg("index", "gender") .g("id").coerceTo("array"), heroines -> r.table("villains").getAll(r.args(heroines)) ).run(conn);
getAll 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
getAll and other commands; read the full article on secondary indexes for examples using boolean operations,
contains and more.
Couldn't find what you were looking for?