jsonb query in AREL
Asked Answered
C

0

6

I'm fairly new to AREL, and have had trouble finding references to using Postgres JSONB with AREL.

How might I convert this SQL into an AREL statement?

SELECT
    tag,
    count(tag)
FROM
    people p,
    jsonb_array_elements(p.data->'tags') tag 
WHERE p.data->'tags' ? '#{tag}' 
GROUP BY tag
Cytology answered 6/9, 2016 at 9:50 Comment(1)
You may find the ActiveRecordExtended gem helpfulAcidforming

© 2022 - 2024 — McMap. All rights reserved.