struct Country: Decodable \{
let id: Int
let name: String
\}
let country: Country = try await supabase.database
.from("countries")
.update(["name": "Australia"], returning: .representation)
.eq("id", value: 1)
// If you know this query should return a single object, append a `single()` modifier to it.
.single()
.execute()
.value
Updating JSON data
struct User: Decodable \{
let id: Int
let name: String
let address: Address
struct Address: Codable \{
let street: String
let postcode: String
\}
\}
struct UpdateUser: Encodable \{
let address: User.Address
\}
let users: [User] = try await supabase.database
.from("users")
.update(
UpdateUser(
address: .init(
street: "Melrose Place",
postcode: "90210"
)
),
returning: .representation
)
.eq("address->postcode", value: "90210")
.execute()
.value