SurrealSession is the base class of SurrealClient and the type returned by .newSession(). It exposes the full querying, authentication, and CRUD API with state — authentication, namespace, database, and parameters — isolated to that session. See Multiple sessions for the concept.
Source: surrealdb.kotlin
Shared API
Because SurrealClient extends SurrealSession, every session — root or child — provides the same methods documented on the client:
Connection:
.use(),.ping(),.version()Authentication:
.signin(),.signup(),.authenticate(),.auth(),.invalidate(),.reset()Queries:
.query(),.queryAs<T>(),.let(),.unset()
Session state accessors
| Method | Type | Description |
|---|---|---|
.namespace() | String? | The session's current namespace. |
.database() | String? | The session's current database. |
.accessToken() | String? | The session's current access token, if authenticated. |
Creating and closing sessions
Transactions
Transactions are started on a session via the transaction { } and beginTransaction() extension functions. See the Transaction reference.