Perform an UPDATE on the table or view.
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.update
will not return the inserted data. If you want to return the inserted data, you can use the select()
method inside the request.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)
\}
\}