Spec-Zone.ru › RethinkDB java

ReQL command: forEach

Command syntax

result.forEach(doc -> { ... })

Description

Lazily iterate over a result set one element at a time.

RethinkDB results can be iterated through via the Java Iterable and Iterator interfaces; use standard Java commands like for loops to access each item in the sequence.

Example: Let’s process all the elements!

try (Result<Object> result = r.table("users").run(conn)) {
    result.forEach(doc -> { System.out.println(doc); });
}

Example: Stop the iteration prematurely.

try (Result<Object> result = r.table("users").run(conn)) {
    for (Object doc: result) {
        if (!processRow(doc)) {
            break;
        }
    }
}

Related commands

  • next
  • toList
  • close (result)

© RethinkDB contributors
Licensed under the Creative Commons Attribution-ShareAlike 3.0 Unported License.
https://rethinkdb.com/api/java/each/

Spec-Zone.ru

Настройки Оффлайн Что нового Помощь О нас
Spec-Zone .ru
спецификации, руководства, описания, API