Is there an equivalent for arrayUnion or arrayRemove in Supabase? #753
Unanswered
cdedreuille
asked this question in
Questions
Replies: 1 comment 1 reply
-
There's no create or replace function extensions.array_union(a1 anyarray, a2 anyarray) returns anyarray as $$
select array_agg(arr order by arr)
from (
select distinct unnest(a1 || a2) as arr
) _;
$$ language sql; Then this will work for any type of array(try it on the SQL Editor): select array_union(ARRAY[1,2,3], ARRAY[2,3,4,5,6]);
[1,2,3,4,5,6]
select array_union(ARRAY['a','b','c'], ARRAY['b','c','d','e']);
["a","b","c","d","e"] For select array_remove(ARRAY[1,2,3], 2);
[1,3] |
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Hi,
I was wondering if there was an easy way to update an array in Supabase avoiding any duplications. In firebase I'm using
FieldValue.arrayUnion(element)
. Is there an equivalent in Supabase or an alternative way to do this?Beta Was this translation helpful? Give feedback.
All reactions