This guide walks through a minimal Mojo program that connects to a local SurrealDB instance, runs a query, and reads the result. It assumes you have already installed the SDK.
Start SurrealDB
Start a local SurrealDB with an in-memory store, using the CLI or Docker:
Connect and run a query
Create a Mojo file and connect over HTTP. The access_token here is the base64 encoding of root:root, sent as HTTP Basic auth.
Run it:
Work with records
The client exposes convenience methods that wrap common SurrealQL statements. Each takes the table or record to act on and a JSON document.
Read the response
Every call returns an RpcResponse. Check is_ok() before reading the result, and inspect the error fields otherwise.
Next steps
Connecting to SurrealDB for transports, wire formats, and TLS.
Executing queries for working with responses and convenience methods.
Authentication for signing in and managing credentials.
SDK methods for the full method reference.