The Kotlin SDK provides fluent builders for the common CRUD operations. Each builder method (such as .select() or .create()) returns a query builder that you refine and then terminate with await() (raw JsonElement) or the typed awaitAs<T>() extension. Under the hood these compile to SurrealQL and dispatch through .query(), mirroring the JavaScript SDK.
API references
| Method | Description |
|---|---|
client.select(what) | Selects records from a table or record |
client.create(what) | Creates a record |
client.update(what) | Replaces the content of records |
client.upsert(what) | Creates or updates records |
client.merge(what, data) | Merges data into records |
client.patch(what, patches) | Applies JSON patches to records |
client.delete(what) | Deletes records |
client.relate(in, relation, out) | Creates a graph edge between records |
client.insert(into, data) | Inserts one or more records |
The what argument accepts a Table to target every record in a table, a RecordId to target a single record, or a RecordIdRange to target a range.
Creating records
Build content with buildJsonObject and finish with the typed awaitAs<T>().
Selecting records
Refine a select with .where(), .limit(), .start(), .fetch(), and others, using the expression helpers.
Updating and merging
Use .update() to replace record content, .merge() to merge data, or .upsert() to create or update. Control the returned payload with .returnMode().
Deleting records
Relating records
Create a graph edge between two records with .relate().
Learn more
Query builder reference for every builder method and expression helper
Executing queries for raw SurrealQL
Value types for
Table,RecordId, and the JSON modelSerialization for decoding into your own types