I have something like this: ``` const { data, erro...
# javascript
l
I have something like this:
Copy code
const { data, error } = await locals.supabase.from('goals').select(`
    id,
    time,
    player:playerId (
      id,
      name
    ),
    team:teamId (
      id,
      name
    ),
    opponent:opponentId (
      id,
      name
    )
`)
How can I filter the query results by player name for example?
g
Please continue here.
l
My doubt is what is the asterisk in the inner function? Should I put there the fields of the joined table?
And how is it used with column aliases
g
First you should be able to just use player,team, opponent without the actual column.
l
Player, yes, but team and opponent refer to the same foreign table
g
Can you show your goals table columns.
l
Sure
id,created_at,gamePk,date,period,periodTime,title,blurb,description,duration,thumbnail,rawVideoUrl,teamId,opponentId,playerId,embedVideoUrl,timestamp
The foreign keys are
teamId
,
opponentId
and
playerId
g
You are going to be plagued with issues using caps in your names. Is this forced by Prisma?
l
Oh 😬
No. I am just used to camelCase
l
I will switch to snake_case
g
You do have a more difficult case of using inner with 3 keys to same table. I think this is the format you need but not positive:
player:player_id!inner(id,name)
The question is then what goes in the filter:
.eq('player.name', 'Jane')
or
.eq('player_id.name', 'Jane')
or something else....
I see some examples with just the alias player in the filter.
l
Let me try that.
I think I tried this exact thing already and it didn't work with camelCase, but now with snake_case it seems to work 🙂
It works both with
'player.name'
and
'player_id.name'
g
Thanks for letting me know last part.