SunTzu
05/26/2023, 3:17 PMSELECT * FROM messages m WHERE m.sources::text LIKE '%"document": 25%';
And works completely fine,
I'm trying to replicate this with the js library
const { data, error } = await supabase
.from("messages")
.select(`*`)
.like("sources", `%"document": ${id}%]`);
however unsure how I replicate the ``::text`` as like the SQL querygaryaustin
05/26/2023, 3:18 PMgaryaustin
05/26/2023, 3:19 PMSunTzu
05/26/2023, 3:57 PMSunTzu
05/26/2023, 3:57 PMvick
05/26/2023, 4:41 PMvick
05/26/2023, 4:43 PMvick
05/26/2023, 4:45 PMsources->>'document' = 25
SunTzu
05/26/2023, 6:07 PMcolumn name: sources
data example:
[{"metadata":{"loc":{"lines":{"to":668,"from":668}},"index":135,"active":true,"chatbots":[2],"document":36}}]
So its like sources->>metadata->>document?vick
05/26/2023, 6:35 PMsources->0->metadata->>document
. The ->> gives you a string, and you're inside an array.vick
05/26/2023, 6:36 PMpostgres=> select '[{"metadata":{"loc":{"lines":{"to":668,"from":668}},"index":135,"active":true,"chatbots":[2],"document":36}}]'::jsonb->0->'metadata'->>'document';
?column?
----------
36
(1 row)
SunTzu
05/28/2023, 1:38 AMconst { data, error } = await supabase
.from("messages")
.select(`*`)
.eq("sources->0->metadata->>document", String(23));