CallumBoase / plasmic-supabase

GNU General Public License v3.0
7 stars 5 forks source link

Optimistic operations don't support bulk actions #29

Open ryanmouritz opened 2 months ago

ryanmouritz commented 2 months ago

Supabase supports bulk actions for INSERT, UPSERT and DELETE operations by taking an array of objects and/or values (slight difference in syntax for each). It is currently possible to use the bulk operations for supabase in the INSERT action in Plasmic-supabase SupabaseProvider component by providing an array of objects as the rowForSupabase argument, despite them not being explicitly typed.

ISSUE/PROBLEM: Whilst a bulk INSERT can be performed for Supabase, optimistic updates for addRow doesn't support adding multiple rows optimistically due to using the spread method to join the new Row object to the existing array of Rows.

NOTE: It should be noted a bulk DELETE operation won't work in the current implementation due to the query syntax using .in comparator vs a .eq comparator for a single id.

POTENTIAL FEATURE ADDITION: Formally support bulk supabase operations and the corresponding bulk optimistic updates by identifying if the rowForSupabase is an array and using an alternative join method if so.