Reputation: 273
I want to retrieve rows based on a value being present in text column defined as multidimensional array in Supabase
I am trying to query this records using following urls
https://DATABASE_URL.supabase.co/rest/v1/test_db?data=in.({"1"})
https://DATABASE_URL.supabase.co/rest/v1/test_db?data=in.(1)
But doesnt seem to work. Error message was operator does not exist: text[] ~~ unknown
with hint being No operator matches the given name and argument types. You might need to add explicit type casts.
Any help will be appreciated! Thanks in advance.
Upvotes: 2
Views: 2223
Reputation: 458
To filter by the values inside of an array, you can use the cs
operator, which is equivalent to @>
(contains) in PostgreSQL.
For instance, this query will retrieve all the rows that have the value "1"
present in the array of the data
column.
https://DATABASE_URL.supabase.co/rest/v1/test_db?data=cs.{"1"}
Upvotes: 4