DBIx::DataModel::Schema::ResultAs::Hashref(3p)

NAME
DBIx::DataModel::Schema::ResultAs::Hashref - arrange data rows in a hash

SYNOPSIS
  my $tree = $source->select(..., -result_as => 'hashref');
  # or
  my $tree = $source->select(..., -result_as => [hashref => ($column1, ...)]);
  # or
  my $tree = $source->select(..., -result_as => [hashref => sub {...}]);

DESCRIPTION
Returns a nested tree of hashrefs; leaves of the tree are data rows, and keys of the hashes are column values. The depth of the tree corresponds to the number of columns given as argument. In most cases there is just one single column, so the result is just an ordinary hashref.

This "-result_as" is normally used only in situations where the key fields values for each row are unique. If multiple rows are returned with the same values for the key fields then later rows overwrite earlier ones.

Instead of a list of column names, the argument can be a reference to a subroutine. That subroutine will we called for each row and should return a list of scalar values to be used as hash keys.

In absence of column or sub arguments, the primary key of the $source will be used.