• Start

Languages

/

Swift

/

Methods

query

The query() method for the SurrealDB Swift SDK runs a query built with the query DSL or macros.

Runs a query built with the query DSL, either a query macro such as #select or a SurrealDSL builder call.

Method Syntax

try await client.query(query)
ArgumentsDescription
query A query produced by a query macro or a SurrealDSL builder call.
// Using a query macro
let selectQuery = #select(Person.self, where: Person.Fields.age > 18, limit: 10)
let people = try await client.query(selectQuery)

// Using the SurrealDSL builder
let query = SurrealDSL.select(Person.self, where: Person.Fields.age >= 21, limit: 50)
let result = try await client.query(query)

For arbitrary SurrealQL, see queryRaw.

Was this page helpful?