The Swift SDK exposes its functionality through the SurrealHTTPClient and SurrealWebSocketClient types, which share the same API. This page lists the methods available on a connected client.
Initialization methods
| Method | Description |
|---|---|
client.connect() | Connects the client to the underlying endpoint |
client.use(namespace, database) | Switch to a specific namespace and database |
Authentication methods
| Method | Description |
|---|---|
client.signup(credentials) | Signs this connection up to a specific authentication access |
client.signin(credentials) | Signs this connection in to a specific authentication level |
client.authenticate(token) | Authenticates the current connection with a JWT token |
client.invalidate() | Invalidates the authentication for the current connection |
Query methods
| Method | Description |
|---|---|
client.select(model) | Selects all records in a table, or a specific record |
client.query(query) | Runs a query built with the query DSL or macros |
client.queryRaw(sql, bindings) | Runs a raw SurrealQL query with bound parameters |
client.live(query) | Subscribes to changes via a live query (WebSocket only) |
client.kill(liveQueryID) | Kills a running live query |
Mutation methods
| Method | Description |
|---|---|
client.create(model) | Creates a record in the database |
client.update(model) | Updates matching records, or a specific record |
client.upsert(model) | Creates or updates matching records |
client.delete(model) | Deletes matching records, or a specific record |