SELECT if array column is NULL or DOESN'T contain input value in Supabase

Viewed 32

I want to write an SELECT statement using Supabase-JS library, where it would return all rows whose associated_campaigns (array of UUIDs) column is either null or doesn't contain input string.

I'm trying with something like this, where campaign_id is input parameter, but without success:

supabase.from("linkedin_leads").select("*").or(`associated_campaigns.is.null,not(associated_campaigns.cs.${campaign_id})`);

Error returned is:
"failed to parse logic tree ((associated_campaigns.is.null,not(associated_campaigns.cs.e04a95fc-47bd-4c88-8e97-ad48711ee8d9)))"
1 Answers

Looking at the docs for contains, it looks like you might have to wrap your campaign_id in {} like this:

supabase.from("linkedin_leads").select("*").or(`associated_campaigns.is.null,not(associated_campaigns.cs.{${campaign_id}})`);
Related