GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Close
  • FAQ
  • Docs
  • API
  • Community
  • Blog
  • Accessing ReQL
  • r
  • connect
  • close
  • reconnect
  • use
  • run
  • changes

This view

  • Original page
  • New address

GeezerVison is showing rethinkdb.com — ReQL command reference - RethinkDB


▲ Back to top

Command syntax

table.getAll([key, key2...], [, {index:'id'}]) → selection

Description

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').getAll('man_of_steel', {index:'code_name'}).run(conn, callback)

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.

r.table('dc').getAll('superman').run(conn, callback)

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

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

Note: 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', {index: 'gender'})('id').coerceTo('array'),
    function(heroines) {
        return r.table('villains').getAll(r.args(heroines));
    }
).run(conn, callback)

Calling 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.

Related commands

  • get
  • between
  • filter

Get more help

Couldn't find what you were looking for?

  • Ask a question on Stack Overflow
  • Chat with us and our community on Slack
  • Talk to the team on IRC on #[email protected] — via Webchat
  • Ping @rethinkdb on Twitter
  • Post an issue on the documentation issue tracker on GitHub

Contribute: edit this page or open an issue

You are visitor 01402520 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.