I need support to solve the following, I am using objection.js
with Postgresql
14.5 and node.js, I have a table called articles with a JSON column called properties.
the jsonb properties column is structured as follows:
{
characteristics: [
{
attributes: [
{
name: '<string text>',
attribute_id: '<id value>',
attribute_value: '<string text>', // < ----- string text
},
],
specification_id: '<id value>',
},
{
attributes: [
{
attribute_value: 30, // < ----- int number
},
],
specification_id: '<id value>',
},
],
}
the query is for attributes[any position] .attribute_value where is int number
I need to do an or Where query, where specification_id is equal to the id I assign to it; and attributes.attribute_value is less than X number that I assign to it. written example: specification_id: '12e8de7a-5dd8-4614-bd56-e6335d216ea1' and attributes.attribute_value < 30
and I need to do another or Where query, where specification_id is equal to the id I assign to it; and attributes.attribute_value is greater than X number that I assign written example: specification_id: '12e8de7a-5dd8-4614-bd56-e6335d216ea1' and attributes.attribute_value > 30
and I need to do another or Where query, where specification_id is equal to the id I assign to it; and attributes.attribute_value is greater than or equal to X number that I assign to it, or less than or equal to X number that I assign to it. written example: specification_id: '12e8de7a-5dd8-4614-bd56-e6335d216ea1' and (attributes.attribute_value >= 25 and attributes.attribute_value <= 31)
I hope I have explained myself, an apology for my bad English.