• Start

Languages

/

Java

/

API Reference

/

Data types

RecordId

The RecordId class represents a SurrealDB record identifier consisting of a table name and an ID value.

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

Creates a record ID with a numeric identifier.

Method Syntax
new RecordId(table, id)

Parameter

Type

Description

tableString

The table name.

idlong

The numeric record identifier.

Example
RecordId id = new RecordId("person", 1);

Creates a record ID with a string identifier.

Method Syntax
new RecordId(table, id)

Parameter

Type

Description

tableString

The table name.

idString

The string record identifier.

Example
RecordId id = new RecordId("person", "tobie");

Creates a record ID with a UUID identifier.

Method Syntax
new RecordId(table, id)

Parameter

Type

Description

tableString

The table name.

idUUID

The UUID record identifier.

Example
RecordId id = new RecordId("person", UUID.randomUUID());

Creates a record ID with a composite key using an array.

Method Syntax
new RecordId(table, id)

Parameter

Type

Description

tableString

The table name.

idArray

The composite key as an array.

Creates a record ID with a composite key using an object.

Method Syntax
new RecordId(table, id)

Parameter

Type

Description

tableString

The table name.

idObject

The composite key as an object.

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();

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();

The Id class represents the identifier part of a RecordId. It wraps the underlying value and provides type checking and extraction methods.

Creates an Id from a numeric value.

Method Syntax
Id.from(id)

Parameter

Type

Description

idlong

The numeric identifier.

Returns: Id

Creates an Id from a string value.

Method Syntax
Id.from(id)

Parameter

Type

Description

idString

The string identifier.

Returns: Id

Creates an Id from a UUID value.

Method Syntax
Id.from(id)

Parameter

Type

Description

idUUID

The UUID identifier.

Returns: Id

MethodReturns 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
MethodReturn TypeDescription
getLong()longReturns the numeric ID value
getString()StringReturns the string ID value
getUuid()UUIDReturns the UUID ID value
getArray()ArrayReturns the composite array key
getObject()ObjectReturns the composite object key

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.

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

tableString

The table name.

startId

The start of the range. Pass

null

for an unbounded start.

endId

The end of the range. Pass

null

for an unbounded end.

Returns the table name of this range.

Method Syntax
range.getTable()

Returns: String

Returns the start bound of the range, or null if unbounded.

Method Syntax
range.getStart()

Returns: Id (nullable)

Returns the end bound of the range, or null if unbounded.

Method Syntax
range.getEnd()

Returns: Id (nullable)

Selecting a range of records
RecordIdRange range = new RecordIdRange("users", Id.from(1), Id.from(100));
List<Value> results = db.select(range);

Was this page helpful?