• Start

Methods

queryRaw

The queryRaw() method for the SurrealDB Swift SDK runs a raw SurrealQL query with bound parameters.

Executes a raw SurrealQL string with bound parameters and returns one RPCQueryResult per statement.

Method Syntax
try await client.queryRaw(sql, bindings: bindings)

Arguments

Description

sql

The raw SurrealQL query to execute.

bindings

A dictionary of SurrealValue parameters referenced in the query.

let results: [RPCQueryResult] = try await client.queryRaw(
    "SELECT * FROM person WHERE age > $minAge LIMIT $limit;",
    bindings: [
        "minAge": .int(18),
        "limit": .int(50)
    ]
)

for row in results {
    if row.status == .ok {
        print(row.result)
    }
}

Was this page helpful?