Perform an UPSERT on the table or view. Depending on the column(s) passed to onConflict
, .upsert()
allows you to perform the equivalent of .insert()
if a row with the corresponding onConflict
columns doesn't exist, or if it does exist, perform an alternative action depending on ignoreDuplicates
.
values
to use upsert.The values to upsert with. Pass an object to upsert a single row or an array to upsert multiple rows.
Named parameters
const \{ data, error \} = await supabase
.from('countries')
.upsert(\{ id: 1, name: 'Albania' \})
.select()
const \{ data, error \} = await supabase
.from('countries')
.upsert([
\{ id: 1, name: 'Albania' \},
\{ id: 2, name: 'Algeria' \},
])
.select()
const \{ data, error \} = await supabase
.from('users')
.upsert(\{ id: 42, handle: 'saoirse', display_name: 'Saoirse' \}, \{ onConflict: 'handle' \})
.select()