fig.newton
03/11/2022, 8:11 AM| uuid | data |
-----------------------------------------------------------
| cafe | {"foo": "bar", "applications": [{"job": "baz"}]} |
So far this plain SQL query works:
SELECT c.uuid, c.data
FROM candidate as c
WHERE c.data->'applications' @> '[{"job": "baz"}]'::jsonb
as does this:
SELECT c.uuid, c.data
FROM candidate as c
WHERE EXISTS (
SELECT TRUE
FROM jsonb_array_elements(data->'applications') AS apps
WHERE apps->>'job' IN ('baz')
)`
but I’m pretty stumped about translating this to a Supabase query.
The PostgREST docs do mention that these JSON operations should be possible, but it’s not clear how to safely construct this query. The only thing that comes to mind is something like "'[{\"job\": \"" + job_id_here "\"}]'" 😦Needle
03/11/2022, 8:11 AM/title
command!
Done using the thread?
Click the button below to archive it.