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()`](/docs/reference/kotlin/api/core/surreal-client#query), [`.queryAs()`](/docs/reference/kotlin/api/core/surreal-client#query-as), [`.let()`](/docs/reference/kotlin/api/core/surreal-client#let), [`.unset()`](/docs/reference/kotlin/api/core/surreal-client#unset)
CRUD builders:
.select(),.create(),.update(),.upsert(),.merge(),.patch(),.delete(),.relate(),.insert()
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
val session = client.newSession()
session.signin(buildJsonObject { put("user", "a"); put("pass", "a") })
session.use("acme", "main")
// ... use the session ...
client.closeSession(session)Transactions
Transactions are started on a session via the transaction { } and beginTransaction() extension functions. See the Transaction reference.