• Start

Methods

query

The query() method for the SurrealDB Mojo SDK runs one or more SurrealQL statements against the database.

Runs one or more SurrealQL statements against the database and returns an RpcResponse.

Method Syntax
client.query(query, bindings_json, session, txn)

Argument

Description

query

The SurrealQL statements to run.

bindings_json

Optional bindings as a JSON string. Defaults to

"{}"

.

session

An optional session id.

txn

An optional transaction id.

var resp = client.query("SELECT * FROM person WHERE age > 18;")

if resp.is_ok():
    if resp.result:
        print(resp.result.value())
else:
    print("error:", resp.error_message().value())
Note

A dedicated API for passing arbitrary CBOR bindings is on the roadmap. Today, CBOR connections support the default "{}", while JSON-RPC connections accept raw JSON strings via bindings_json.

Was this page helpful?