• Start

API Reference

/

Data types

Range

SurrealDB range values are accessed through Value methods for start and end bounds.

SurrealDB range values represent a bounded interval. In the Java SDK, ranges are accessed through Value methods that return the start and end bounds.

Note

For record ID ranges used in CRUD operations (select, update, delete), see RecordIdRange.

Checks if the value is a range.

Method Syntax
value.isRange()

Returns: boolean

Returns the start bound of the range, if present.

Method Syntax
value.getRangeStart()

**Returns:** `Optional`

Returns the end bound of the range, if present.

Method Syntax
value.getRangeEnd()

**Returns:** `Optional`

Working with range values
import com.surrealdb.Surreal;
import com.surrealdb.Response;
import com.surrealdb.Value;
import com.surrealdb.signin.RootCredential;

try (Surreal db = new Surreal()) {
    db.connect("ws://localhost:8000");
    db.useNs("surrealdb").useDb("docs");
    db.signin(new RootCredential("root", "root"));

    Response response = db.query("RETURN 1..10");
    Value result = response.take(0);

    if (result.isRange()) {
        Optional<Value> start = result.getRangeStart();
        Optional<Value> end = result.getRangeEnd();
    }
}

Was this page helpful?