postgrest-js
postgrest-js copied to clipboard
Batch delete is subject to max URL length
Discussed in https://github.com/supabase/supabase/discussions/4831
Originally posted by pryme0 January 6, 2022 Is there a way to do batch delete with supbase? Like i pass in an array containing id's of records i want to delete and it runs the operation for me
definitely:
const { data, error } = await supabase
.from('cities')
.delete()
.in('id', ['1', '2'])
I have a join table using multiple fields as a primary id. For simplicity say user_colors. Perhaps I first add 4 user_colors supabase.from('user_colors').upsert([ {user_id: 'bill', color_id: 'red'}, {user_id: 'bill', color_id: 'green'}, {user_id: 'bill', color_id: 'blue'}]) and I now want to delete the ones with user_id as bill and colors red and green and keep blue
How does this look in that case?
@24jr Can you ask that one in a new discussion? https://github.com/supabase/supabase/discussions
upsert seems unrelated to this one.
With filter in aren’t we limited to the length of url params ? When we have lots of items to delete with long string ids, for instance.
@aiibe Yes, see https://github.com/PostgREST/postgrest/issues/2314. A bulk delete with a request payload is being worked on https://github.com/PostgREST/postgrest/pull/2355.
Repurposing this issue to batch delete w/ request body