RecordId
A RecordId uniquely identifies a record in SurrealDB. It consists of a table name and an ID value. The ID can be a long, String, UUID, or a composite key using Array or Object. See the SurrealQL record ID documentation for details on how record identifiers work in SurrealDB.
Source: surrealdb.java
Constructors
RecordId(String table, long id)
Creates a record ID with a numeric identifier.
Method Syntax
new RecordId(table, id)
| Parameter | Type | Description |
|---|
table required | String | The table name. |
id required | long | The numeric record identifier. |
Example
RecordId id = new RecordId("person", 1);
RecordId(String table, String id)
Creates a record ID with a string identifier.
Method Syntax
new RecordId(table, id)
| Parameter | Type | Description |
|---|
table required | String | The table name. |
id required | String | The string record identifier. |
Example
RecordId id = new RecordId("person", "tobie");
RecordId(String table, UUID id)
Creates a record ID with a UUID identifier.
Method Syntax
new RecordId(table, id)
| Parameter | Type | Description |
|---|
table required | String | The table name. |
id required | UUID | The UUID record identifier. |
Example
RecordId id = new RecordId("person", UUID.randomUUID());
RecordId(String table, Array id)
Creates a record ID with a composite key using an array.
Method Syntax
new RecordId(table, id)
| Parameter | Type | Description |
|---|
table required | String | The table name. |
id required | Array | The composite key as an array. |
RecordId(String table, Object id)
Creates a record ID with a composite key using an object.
Method Syntax
new RecordId(table, id)
| Parameter | Type | Description |
|---|
table required | String | The table name. |
id required | Object | The composite key as an object. |
Methods
.getTable()
Returns the table name of this record ID.
Method Syntax
recordId.getTable()
Returns: String
Example
RecordId id = new RecordId("person", "tobie");
String table = id.getTable();
.getId()
Returns the identifier part of this record ID.
Method Syntax
recordId.getId()
Returns: Id
Example
RecordId id = new RecordId("person", "tobie");
Id identifier = id.getId();
Id
The Id class represents the identifier part of a RecordId. It wraps the underlying value and provides type checking and extraction methods.
Static Factory Methods
Id.from(long id)
Creates an Id from a numeric value.
Method Syntax
Id.from(id)
| Parameter | Type | Description |
|---|
id required | long | The numeric identifier. |
Returns: Id
Id.from(String id)
Creates an Id from a string value.
Method Syntax
Id.from(id)
| Parameter | Type | Description |
|---|
id required | String | The string identifier. |
Returns: Id
Id.from(UUID id)
Creates an Id from a UUID value.
Method Syntax
Id.from(id)
| Parameter | Type | Description |
|---|
id required | UUID | The UUID identifier. |
Returns: Id
Type Checking Methods
| Method | Returns true when |
|---|
isLong() | The ID is a numeric value |
isString() | The ID is a string value |
isUuid() | The ID is a UUID value |
isArray() | The ID is a composite array key |
isObject() | The ID is a composite object key |
Getter Methods
| Method | Return Type | Description |
|---|
getLong() | long | Returns the numeric ID value |
getString() | String | Returns the string ID value |
getUuid() | UUID | Returns the UUID ID value |
getArray() | Array | Returns the composite array key |
getObject() | Object | Returns the composite object key |
RecordIdRange
The RecordIdRange class represents a range of record IDs within a table. It can be used with methods like select to retrieve a subset of records.
Constructor
RecordIdRange(String table, Id start, Id end)
Creates a range of record IDs. Pass null for start or end to leave that bound open.
Method Syntax
new RecordIdRange(table, start, end)
| Parameter | Type | Description |
|---|
table required | String | The table name. |
start optional | Id | The start of the range. Pass null for an unbounded start. |
end optional | Id | The end of the range. Pass null for an unbounded end. |
Methods
.getTable()
Returns the table name of this range.
Method Syntax
range.getTable()
Returns: String
.getStart()
Returns the start bound of the range, or null if unbounded.
Method Syntax
range.getStart()
Returns: Id (nullable)
.getEnd()
Returns the end bound of the range, or null if unbounded.
Method Syntax
range.getEnd()
Returns: Id (nullable)
Example
Selecting a range of records
RecordIdRange range = new RecordIdRange("users", Id.from(1), Id.from(100));
List<Value> results = db.select(range);
See Also