postgrest-js icon indicating copy to clipboard operation
postgrest-js copied to clipboard

Batch delete is subject to max URL length

Open pryme0 opened this issue 3 years ago • 6 comments
trafficstars

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

pryme0 avatar Jan 06 '22 12:01 pryme0

definitely:

const { data, error } = await supabase
  .from('cities')
  .delete()
  .in('id', ['1', '2'])

kiwicopple avatar Jan 06 '22 14:01 kiwicopple

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 avatar Jul 17 '22 14:07 24jr

@24jr Can you ask that one in a new discussion? https://github.com/supabase/supabase/discussions

upsert seems unrelated to this one.

steve-chavez avatar Jul 19 '22 00:07 steve-chavez

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 avatar Jul 22 '22 16:07 aiibe

@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.

steve-chavez avatar Jul 22 '22 17:07 steve-chavez

Repurposing this issue to batch delete w/ request body

soedirgo avatar Sep 27 '22 07:09 soedirgo