Java Types
The SDK provides several supporting types for authentication, update operations, and relation modeling. These types are used as parameters to methods on the Surreal class.
Source: surrealdb.java
Authentication Types
Credential
Interface. Base type for all credentials passed to signin() and signup().
Signin
Interface. Extends Credential. Marker interface for sign-in credentials.
RootCredential
Implements Signin. Authenticates as a root user.
| Parameter | Type | Description |
|---|---|---|
username | String | The root username. |
password | String | The root password. |
Methods
| Method | Returns | Description |
|---|---|---|
.getUsername() | String | The root username |
.getPassword() | String | The root password |
NamespaceCredential
Extends RootCredential. Authenticates as a namespace user.
| Parameter | Type | Description |
|---|---|---|
username | String | The namespace username. |
password | String | The namespace password. |
namespace | String | The namespace to authenticate against. |
Additional Method
| Method | Returns | Description |
|---|---|---|
.getNamespace() | String | The target namespace |
DatabaseCredential
Extends NamespaceCredential. Authenticates as a database user.
| Parameter | Type | Description |
|---|---|---|
username | String | The database username. |
password | String | The database password. |
namespace | String | The namespace containing the database. |
database | String | The database to authenticate against. |
Additional Method
| Method | Returns | Description |
|---|---|---|
.getDatabase() | String | The target database |
RecordCredential
Implements Credential. Authenticates as a record user via an access method defined with DEFINE ACCESS.
| Parameter | Type | Description |
|---|---|---|
namespace | String | The namespace. Omit to use the session namespace. |
database | String | The database. Omit to use the session database. |
access | String | The access method name. |
params | Object | Additional fields required by the access definition. |
Methods
| Method | Returns | Description |
|---|---|---|
.getNamespace() | String | The target namespace |
.getDatabase() | String | The target database |
.getAccess() | String | The access method name |
.getParams() | Object | The additional parameters |
BearerCredential
Implements Credential. Authenticates with an existing token.
| Parameter | Type | Description |
|---|---|---|
token | String | A valid JWT token string. |
Method
| Method | Returns | Description |
|---|---|---|
.getToken() | String | The bearer token |
Token
Represents authentication tokens returned by signin() and signup().
| Parameter | Type | Description |
|---|---|---|
access | String | The access token (JWT). |
refresh | String | The refresh token. May be null. |
token | String | A single token string (legacy constructor). |
Methods
| Method | Returns | Description |
|---|---|---|
.getAccess() | String | The access token (JWT) |
.getRefresh() | String | The refresh token (may be null) |
.getToken() | String | The access token |
Operation Types
UpType
Enum for update() and upsert() operation types.
| Value | Description |
|---|---|
CONTENT | Replaces the entire record content |
MERGE | Merges fields with the existing record |
PATCH | Applies partial changes |
Relation Types
Relation
POJO base class for graph relations. Contains the standard relation fields. Used with relate().
Fields
| Field | Type | Description |
|---|---|---|
id | RecordId | The relation record ID |
in | RecordId | The source record |
out | RecordId | The target record |
InsertRelation
POJO for inserting relations. Uses Id instead of RecordId for the id field. Used with insertRelation().
Fields
| Field | Type | Description |
|---|---|---|
id | Id | The relation ID |
in | RecordId | The source record |
out | RecordId | The target record |
Utility Types
NsDb
Holds a namespace and database pair.
Methods
| Method | Returns | Description |
|---|---|---|
.getNamespace() | String | The namespace |
.getDatabase() | String | The database |
See Also
Surreal — Connection and method reference
Authentication — Authentication concepts and patterns
Data manipulation — CRUD operation patterns
DEFINE USER — System user definition for root, namespace, and database credentials
DEFINE ACCESS — Access method definition for record-level authentication