lib/base_repo.rb
# Get an array of ordered values from a dataset.
# Optionally filtered by a WHERE clause.
#
# @param table_name [Symbol] the db table name.
# @param columns [Symbol,Array] the column (or array of columns) to query.
# @param where [Hash] the where-clause conditions. Optional.
# @param order [Symbol] the order by clause.
# @param descending [Boolean] return in decending order. Default is false.
# @return [Array] the values from the column(s) of each row.
Get an array of ordered values from a dataset.
Optionally filtered by a WHERE clause.
Get an array of ordered values from a dataset . Optionally filtered by a WHERE clause .
def select_values_in_order(table_name, columns, where: nil, order:, descending: false)
    ds = DB[table_name]
    ds = ds.where(where) if where
    ds = ds.order(order) if order && !descending
    ds = ds.reverse(order) if order && descending
    ds.select_map(columns)
  end
def select_values_in_order ( table_name , columns , where : nil , order : , descending : false ) ds = DB [ table_name ] ds = ds . where ( where ) if where ds = ds . order ( order ) if order && ! descending ds = ds . reverse ( order ) if order && descending ds . select_map ( columns ) end
Get an array of ordered values from a dataset.
Get an array of ordered values from a dataset .
the values from the column(s) of each row.
the values from the column ( s ) of each row .
Array
table_name
the db table name.
the db table name .
columns
the column (or array of columns) to query.
the column ( or array of columns ) to query .
where
the where-clause conditions. Optional.
the where - clause conditions . Optional .
order
the order by clause.
the order by clause .
descending
return in decending order. Default is false.
return in decending order . Default is false .