Some condition or no records in a table

To query if there are some values less than a certain value, or there are no records, is the best way to do this with an OR with “some” and “every” + “is_empty”? Is there a shorter way to do this?

OR: [
  {
    stories: {
      some: {
        status: {
          value: {
            lt: 5
          }
        }
      }
    }
  }
  {
    stories: {
      every: {
        id: {
          is_empty: true
        }
      }
    }
  }
]

This works because of the logic of some and every, but is there a way to query if there are no stories directly?

1 Like

Hey @mike_ekim1024 - this would be the best approach currently. If you’d like, type some pseudo code on how you think the syntax could be better written.

Some thoughts off the top of my head:

some_or_empty: {
  status: { ... }
}

some(orEmpty: true) {
}

OR: {
  ...
  self: {
    is_empty: true
  }
}

The JavaScript equivalent is something like:

xs.some(x => ...) || xs.length === 0
1 Like