In addition to the high-level CRUD methods, the Swift SDK lets you build queries with a type-safe DSL. You can use either compile-time expression macros or the programmatic SurrealDSL builder, then run the result with query.
Query macros
Expression macros resolve to SurrealDSL calls at compile time. They are the most concise way to express a query:
Run a query with the query method:
Programmatic SurrealDSL builder
SurrealDSL exposes the same operations as plain functions, which is useful when a query is built dynamically:
When creating records through the DSL, pass the content as a binding:
When to use raw queries instead
For arbitrary SurrealQL that the DSL does not model, use queryRaw with bound parameters.