I'm on rails 4 and using Postres 9.4. My code currently is like:
array1 = Model.where(some_condition1).ids
array2 = Model.where(some_condition2).ids
Is there a way to get the same results with only one database read? In the form:
master_array = <the solution>
and each element of master_array is of something like the form (where I know which conditions the id satisfied):
[id, some_condition1?, some_condition2?]
so I can quickly do:
array1 = master_array.select { |n| n[1] }.map { |n| n[0] }
array2 = master_array.select { |n| n[2] }.map { |n| n[0] }