Closed jgaskins closed 10 years ago
In jgaskins/perpetuity#32, it was proposed that we add predicate methods to query attributes to match the ones in Ruby's Enumerable module for queries like this:
Enumerable
Perpetuity[User].select { |user| user.friends.any? }
Using Postgres' json_array_length function, this is totally doable:
json_array_length
count
json_array_length(#{attribute})
any?
attribute.count > 0
none?
!attribute.any?
one?
attribute.count == 1
Fixed in 17867453cbbd8e27c932bb4ac35e38af9cca37fa
In jgaskins/perpetuity#32, it was proposed that we add predicate methods to query attributes to match the ones in Ruby's
Enumerable
module for queries like this:Using Postgres'
json_array_length
function, this is totally doable:count
— SQL:json_array_length(#{attribute})
any?
—attribute.count > 0
none?
—!attribute.any?
one?
—attribute.count == 1