Trying to insert in bulk fails if one of the items already exists
I'm trying to create an entry if one like it doesn't already exist (i.e. if there's no UNIQUE conflict). I want to do this in bulk (it's for inviting users to a project) but if any of the rows conflicts, the whole op fails.
I tried using
.insert(payload)
as well as .upsert(payload, {ignoreDuplicates: true})
and both had the same issue...
I'm using supabase-js (with Next.js)7 Replies
What errors do you get?
which would be fine if the other items in the set were created successfully...
same error when using
.upsert(payload, {ignoreDuplicates: true})
try
{ onConflict: 'unique id' }
Upsert data: upsert() | Supabase
Performs an UPSERT into the table.
replace 'unique id' with your unique id column
success!
thank you!
.upsert(payload, {onConflict: 'project_id, user_id'})
did the trick