1

I have a record that looks like this: { properties: [1,2] }

I want to search to find the field where the properties match exactly.

Record.where("(query)")

So far I tried things I found from this answer including

"properties#>>'{array,0}' = '1'"

to try to get the first element of an array to match.

I just don't understand the query interface for postgres columns at all. Can someone help me out? How do I search for an array with contents I know I want to match exactly?

1 Answer 1

1

To access elements of an array, use their numeric index with the format fieldname->>index

So the answer to the original query is:

properties ->>0 is '1' and properties->>1 is '2'
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.