jar
07/17/2022, 4:26 AMsupabase.from('user_colors').match({user_id: some_user_id}).delete() and supabase.from('user_colors').insert([{user_id: some_user_id, color_id: "red"},{user_id: some_user_id, color_id: "green"},{user_id: some_user_id, color_id: "purple"}])
however I get error that I cannot do two operations on same row aka deleting red and adding red.
perhaps I need to not that red and green are maintained and use .not on the delete for those?
In which case how can I chain methods of nots in a loop
supabase.from('user_colors').match({user_id: some_user_id}).delete().not('color_id', 'eq', 'red').not('color_id', 'eq', 'green')
I assume is how i do then just upsert. But I have js list so how can i do for color in colors loop to add .nots in chain.
And if better way lmk thanks!Needle
07/17/2022, 4:26 AMgaryaustin
07/17/2022, 12:49 PMjar
07/17/2022, 2:28 PMNeedle
07/17/2022, 2:28 PMjar
07/17/2022, 2:59 PMgaryaustin
07/17/2022, 3:01 PMjar
07/17/2022, 3:04 PMconst { data, error } = await supabase
.from('user_colors')
.delete()
.match({user_id : bill})
.in('color_id', ['red', 'green'])
This looks possibly goodgaryaustin
07/17/2022, 3:05 PMjar
07/17/2022, 3:05 PMjar
07/17/2022, 3:06 PMjar
07/17/2022, 3:15 PMerror:
code: "21000"
details: null
hint: "Ensure that no rows proposed for insertion within the same command have duplicate constrained values."
message: "ON CONFLICT DO UPDATE command cannot affect row a second time"
Hmm Ill keep trying to figure out. May just do rpc but gonna try this first withoutNeedle
07/19/2022, 10:56 PM