How to query arrays?

I am getting this error whilst trying to make a query for array values. could not find array type for data type text[] here is my query:
const { data, error } = await supabase
.from('recipes')
.select('*')
.in('tags', ['Snack']);
const { data, error } = await supabase
.from('recipes')
.select('*')
.in('tags', ['Snack']);
Also, I converted my column from JSONB to Text[], does that make any difference?
No description
4 Replies
garyaustin
garyaustin3y ago
You need to use .contains() or one of the other array operators on an array column. .in is for a single value text column. I think contains is what you want for this.
Cheqo
CheqoOP3y ago
I tried contains, but now I get this error:
code
:
"22P02"
details
:
"Token \"Snack\" is invalid."
hint
:
null
message
:
"invalid input syntax for type json"
code
:
"22P02"
details
:
"Token \"Snack\" is invalid."
hint
:
null
message
:
"invalid input syntax for type json"
garyaustin
garyaustin3y ago
Possibly your tags array is not formatted correctly. My text array looks like this: And .contains('testchararray',['cat']) works.
No description
Cheqo
CheqoOP3y ago
Yeah it works now, maybe it was formatted incorrect.

Did you find this page helpful?