• Start

Methods

upsert

The upsert() method for the SurrealDB Swift SDK creates or updates matching records.

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

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.

let upserted = try await client.upsert(
    Person.self,
    content: Person(id: nil, name: "Ada", age: 31),
    where: Person.Fields.name == "Ada"
)

Was this page helpful?