0

I would like to check if a number is in a specific range dynamically. For example i have a table like:

id value age_range
1 a 3-7
2 b 7-10
3 c 3-7
4 d 0-3

if the age of the user is 5, i would like to retrieve all rows where age_range is 3-7 without writing the range in the where clause query. For example something like:

table (where: { 5 in age_range })...
ppichier
  • 1,108
  • 1
  • 16
  • 21
  • I would create view with calculated field and register it hasura. Actually it looks like 'hasura way' - when graphql is not enough, solve it on postgresql level. – Alex Yu Dec 28 '20 at 18:01

1 Answers1

0

Make an age_from and an age_to column if possible.

query MyQuery($int: Int!) {
  table(where: {_and: [{age_to: {_gte: $int}}, {age_from: {_lte: $int}}]}) {
    #Fields....
  }
}
Abraham Labkovsky
  • 1,771
  • 6
  • 12