© 2026 Hedgehog Software, LLC

TwitterGitHubDiscord
More
CommunitiesDocsAboutTermsPrivacy
Search
Star
Setup for Free
SupabaseS
Supabase•4y 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' })
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?
Supabase banner
SupabaseJoin
Supabase gives you the tools, documentation, and community that makes managing databases, authentication, and backend infrastructure a lot less overwhelming.
45,816Members
Resources

Similar Threads

Was this page helpful?
Recent Announcements

Similar Threads

Upsert not working with Row Level Security
SupabaseSSupabase / help-and-questions
3y ago
upsert() new row violates row-level security policy
SupabaseSSupabase / help-and-questions
4y ago
Subscribe to specific row
SupabaseSSupabase / help-and-questions
4y ago
Upsert with 2 conditions
SupabaseSSupabase / help-and-questions
3y ago