This is my query
and it works. I store the list of dictionaries inside my jsonb
column.
SELECT
items.title
FROM
items
WHERE
jsonb_path_exists(items.types::jsonb, '$[*] ? (@.target == "discount")')
Is there any way to write this without jsonb_path_exists()
function?
Also, do JSON Processing Functions use indexing?
I want to simplify the readability/look of my query because it is so long. And curious if I can get any performance improvements by not using JSON Processing Functions.
I tried to replace it with @?
but failed. This is what I used (quote from PostgreSQL):
jsonb @? jsonpath → boolean
Does JSON path return any item for the specified JSON value?
'{"a":[1,2,3,4,5]}'::jsonb @? '$.a[*] ? (@ > 2)' → t
Any help is very much appreciated.