Querying nested arrays in Postgres JSON field with Rails -
i using postgres 9.3 json data type. want query data nested within array.
for example, want query users have of interests = ["music", "movies", "programming"].
thanks!
example:
model user data: { "name": "johndoe1", "github": "johndoe1", "bio": "lorem ipsum dolor sit amet, consectetur adipisicing elit. labore impedit aliquam sapiente dolore magni aliquid ipsa ad, enim, esse ut reprehenderit quaerat deleniti fugit eaque. vero eligendi voluptatibus atque, asperiores.", "blog": "http://johndoe1.example.com", "interests": [ "music", "movies", "programming" ], "age": 35, "newsletter": true }
user.where("data -> 'interests' = '[\"music\", \"movies\", \"programming\"]'")
not working.
Comments
Post a Comment