update()
should always be combined with a filter block to avoid updating all records.insert
or update
, you have to provide a serializable value in the function parameter.The new value, can be either a serializable value or PostgrestUpdate DSL where you can set new values per column.
Additional configuration & filtering for the request.
supabase.from("countries").update(
\{
Country::name setTo "Australia"
//or
set("name", "Australia")
\}
) \{
filter \{
Country::id eq 1
//or
eq("id", 1)
\}
\}
val newCountry = supabase.from("countries").update(
\{
Country::name setTo "Australia"
//or
set("name", "Australia")
\}
) \{
select()
filter \{
Country::id eq 1
//or
eq("id", 1)
\}
\}.decodeSingle<Country>()
val address = Address(street = "Melrose Place", postcode = 90210)
supabase.from("users").update(
\{
User::address setTo address
\}
) \{
filter \{
eq("address->postcode", 90210)
\}
\}