Range
SurrealDB range values represent a bounded interval. In the Java SDK, ranges are accessed through Value methods that return the start and end bounds.
For record ID ranges used in CRUD operations (select, update, delete), see RecordIdRange.
Value methods
.isRange()
Checks if the value is a range.
Method Syntax
value.isRange()
Returns: boolean
.getRangeStart()
Returns the start bound of the range, if present.
Method Syntax
value.getRangeStart()
Returns: Optional<Value>
.getRangeEnd()
Returns the end bound of the range, if present.
Method Syntax
value.getRangeEnd()
Returns: Optional<Value>
Example
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();
}
}
See Also