From 91dabb432ecd559ecf115c02239a6f898447fc26 Mon Sep 17 00:00:00 2001 From: Ben Warren Date: Thu, 4 Jul 2024 23:20:34 -0700 Subject: [PATCH] Refactor Supabase plugin to avoid upsert operations, separate create and update functions --- bun.lockb | Bin 864874 -> 864922 bytes src/sync-plugins/supabase.ts | 41 +++++++++++++++++++++++++---------- 2 files changed, 29 insertions(+), 12 deletions(-) diff --git a/bun.lockb b/bun.lockb index 0a17f351e5c84ce5a43fd9490ac735c4a4da4039..870cc40ce8e50c26ba27466c14fda4797545af4f 100755 GIT binary patch delta 15911 zcmXY&37k&VAI9$(%#3~PvQ9{%7!k6i68;KPWXU$!$uilu#@LrEQ|U&U=3M`~2>6mvi28?)%Q`=Oazm{M2-1*FwdbWOSe3J!XFQ zLi4-F&hK7$e)l5tyBB@Edt9wQ3sq|y?)@{aYvNypqbMedqIjyxUm@?$xN>by8pnbv z6$nvu%8VweYvG@n65GamX$I`z}*U{>kU4ZE@3Do*#QAm?T47Rc; zPHkW*)~p2ESDO`q$)Y56O4&;=KIF z4r#HaQfB30nP#QUD!?8vD-%*>k!VS`GFU2Wrd#=hSvj*RuxHH5hiq9?uv8UkgQbdQ z)nM6XmCUNcHkwrqF(TI){oYxXo*X-ty zd>V@mmRccQW$6~P*02U<9bvj>ZK%Hy>n+$hWXPh6)7ydmB38N8>;~dfX1AHOhy88V zHRQ>no28qO{;|}ZR^iRmf{Ui<3DCuLpcc}Np!5z&e`9eMl1{KA^-kqb`a8W7aWAt$ zFb%uT)ZS*PAx##8EpR9W0-sTb&BOS5g! z8@Adk!>kW%joF-#EsMF9?m}8%X`Wd>SQoSTFr7tzYFo2~A?7R=i!2R9s%B{kOm}P$ zwYb?b=cU4O-Ki@=iY!(lsj~)CcUa1F`ViPoSPj|-&4v>1GFuh0WbueCh9m8<#Tpp@ zq7l>%%vze!o&@MZMp7HoZAr9QAzv12k<^i+slRz{con8IyNCJ>L2cS>voXZ`ocCI2 ze-4X{mc}8?wY14>JZzrX>t<=N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jLDS$84M9#Lk*+cbt0nU$g&noY*U5?W@DQ&jfabji6_Ta1e)&FJ9_MT^%k@`B$@NEaGU*pa8 z;j6jSH3??>@zq*l<;>o3oVu&L*}IMtt6=t?>Ryu5S2=nfkSc*{5de!?w&hgJzOBjkj zoSL5hep-B=s%7-`^N9SGqvFTLmYs}0AqwM1#n;W>F*d$JT)BPvr2=K~_RzF*eAE0h zljFDbPT0ErJYA5#eS7>*rQPS~d}k0?Fz^S75Ph)uY&!23(H t3d&K-=VujEh?|) => { - const res = await client.from(collection).upsert(input).select(); - const { data, error } = res; - if (data) { - const created = data[0]; - return created; - } else { - throw new Error(error?.message); - } - }; - const create = !actions || actions.includes('create') ? upsert : undefined; - const update = !actions || actions.includes('update') ? upsert : undefined; + const create = + !actions || actions.includes('create') + ? async (input: SupabaseRowOf) => { + const res = await client.from(collection).insert(input).select(); + const { data, error } = res; + if (data) { + const created = data[0]; + return created; + } else { + throw new Error(error?.message); + } + } + : undefined; + + const update = + !actions || actions.includes('update') + ? async (input: SupabaseRowOf) => { + const res = await client.from(collection).update(input).eq('id', input.id).select(); + const { data, error } = res; + if (data) { + const created = data[0]; + return created; + } else { + throw new Error(error?.message); + } + } + : undefined; + const deleteFn = !fieldDeleted && (!actions || actions.includes('delete')) ? async (input: { id: SupabaseRowOf['id'] }) => { @@ -184,6 +200,7 @@ export function syncedSupabase< } } : undefined; + const subscribe = realtime ? ({ node, value$, update }: SyncedSubscribeParams) => { const { filter, schema } = (isObject(realtime) ? realtime : {}) as { schema?: string; filter?: string };