if the there's a Team table with a Monsters JSON a...
# javascript
p
if the there's a Team table with a Monsters JSON array property, do we have a way to filter through the Monsters JSON array to find an element ?
g
p
Yeah I saw that, but is it possible to query something like monsters->name (will filter through all names)
Instead of monsters->0->name
g
Possibly using contains with the json path to array and [‘value’] as parameter.
p
something like .contains('monsters->0', ['Monster name']) ?
Do have a small example ?
g
Would need to point to the array is that 0? No example I am just looking at docs.
p
the array is Monsters and it has 10 Items and each item has a Name property
g
What I was thinking was more for {"a":"b","names":["a","b","c"] } so it would not work for {"Monstors":["item1:{"a":"b","Name":"Fred"}","item2":..... if that is what you have..
p
Monsters JSON array is like this: [{ "id": "123", "name": "Mylor"}, { "id": "657", "name": "Grum"}]
It's in a table named teams : { id: "fqd67df", monsters: JSON }
the goal is to find the teams that contains a monster's name
g
Yeah, understand.... I don't have a guess at that. You might be better off with an rpc function and using Postgres methods. I would google and see if you can find some examples in the broader Postgres world. It has alot more json handling than the js client would. https://www.postgresql.org/docs/current/functions-array.html You might post your example in sql thread here (showing your array points out the issue more quickly than your initial question.) Maybe one of the SQL gurus might have an idea...
e
What'd you end up doing?
p
I won’t be using supabase for that use case but something like elastic search