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)
Arguments
Arguments
Description
query
A query produced by a query macro or a SurrealDSL builder call.
Example usage
// 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)