Creates matching records if they do not exist, or updates them if they do.
Method Syntax
try await client.upsert(Model.self, content: content, where: predicate)Arguments
Arguments | Description |
|---|---|
model | The model type to upsert, e.g. Person.self. |
content | The content to write to matching records. |
where | A predicate selecting which records to upsert. |
Example usage
let upserted = try await client.upsert(
Person.self,
content: Person(id: nil, name: "Ada", age: 31),
where: Person.Fields.name == "Ada"
)