Postgres 9.4
I have a record with a JSONB value like this:
{
"attributeA": 1,
"attributeB": "Foo",
"arrayAttribute": [
{"attributeC": 95, "attributeD": 5},
{"attributeC": 105, "attributeD": 5}
]
}
I want to write a query which says:
Find any item where attributeA = 1, attributeB = 'Foo', and for each element in the arrayAttribute array, attributeC is within a 10 point range of some value X. So if X was 100, the above record would match (both 95 and 105 are within 10 points from 100).
I'm really struggling with the JSONB query syntax unfortunately. What's the best way to do this?