Hi everyone. I had a question about using filters ...
# help
c
Hi everyone. I had a question about using filters on a json column from a joined table. Here is the query I am using
Copy code
const { data, error } = await supabase
      .from<definitions['event_verifier']>('event_verifier')
      .select('id,address, createdAt, verifiedAt, event:eventId (id, slug)', { count: 'exact' })
      .eq('event.slug', slug);
What I am noticing is that records that don’t pass the
eq
are still returned, with that field set to null.
Copy code
{
    id: 'f5547b29-4820-4e95-ade5-df6dfbcc07f8',
    address: '0x9372Eb1DfF66859B9e8D05D6014F5d1d87d031c4',
    createdAt: '2022-04-23T19:56:01.486799+00:00',
    verifiedAt: null,
    event: null
  },
I have to take an additional step here and filter through the result to make sure that an event object is there. Is there a way to omit the return result entirely if
.eq('event.slug', slug)
doesn’t pass?
n
Hello @cdro! This thread has been automatically created from your message in #843999948717555735 a ``few seconds ago``. Pinging @User so that they see this as well! Want to unsubscribe from this thread? Right-click the thread in Discord (or use the ... menu) and select Leave Thread to unsubscribe from future updates. Want to change the title? Use the
/title
command! We have solved your problem? Click the button below to archive it.
s
JSON and JSONB in Postgres (and PostgREST) have their own specific operators: https://postgrest.org/en/stable/api.html#json-columns Dot notation isn't really a thing in Postgres when dealing with JSON or JSONB
n
cdro (2022-04-28)
c
Ty!
n
Thread was archived by @cdro. Anyone can send a message to unarchive it.