Updates matching records of a model's table, or a single record by id.
Method Syntax
try await client.update(Model.self, content: content,
where: predicate)Arguments
Arguments | Description |
|---|---|
model | The model type to update, e.g. Person.self. |
content | The content to write to matching records. |
where | A predicate selecting which records to update. |
recordID | A |
Example usage
// Update matching records
let updated = try await client.update(
Person.self,
content: Person(id: nil, name: "Ada", age: 31),
where: Person.Fields.name == "Ada"
)
// Update a specific record
let id = SurrealRecordID(table: "person", id: .string("ada"))
let record: Person? = try await client.update(
recordID: id,
content: Person(id: nil, name: "Ada", age: 31)
)