SupabaseS
Supabase4y ago
enti

Upsert a specific row with API

I got a table with 2 unique columns (both can only contain unique datas)
I want to upsert column_2 according to column_1 (updating column_2 if column_1 data already exists, inserting instead)
My code actually looks like:
const { data, error } = await supabase
  .from('users')
  .upsert({ column_1: 'data1', column_2: 'data2' }, { onConflict: 'column_1' })

So for now, if there's a conflict on column_1, the query does nothing. But I want to update column_2 for that specific existing column_1 conflict instead.
The doc doesn't provide any detail. Do you know how I could provide this request though my supabase API call?
Was this page helpful?