Join the Stack Overflow Community
Stack Overflow is a community of 4.7 million programmers, just like you, helping each other.
Join them; it only takes a minute:
Sign up

I am using Postgres 9.3 json data type. I want to do a query with data that is nested within the array.

For example, I want to query for users that have all of this 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.

share|improve this question

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.