DBIx::Class::ResultSet::Faceter - Faceting for DBIx::Class ResultSets


  my $faceter = DBIx::Class::ResultSet::Faceter->new;

  # Add a Column facet for the name_last column
  $faceter->add_facet('Column', {
        name => 'Last Name', column => 'name_last'
  # Add more, if you like
  $faceter->add_facet('CodeRef', {
    name => 'Avg Test Score', code => sub { # something fancy }

  # Even for HashRefInflator stuff
  $faceter->add_facet('HashRef', {
    name => 'DoB', key => 'date_of_birth'

  # Pass in a resultset and get a results object
  my $results = $faceter->facet($resultset);


Faceter is a mechanism for "faceting" a resultset, or counting the occurrences of certain data. Faceting is a common search pattern, represented by the sidebars that tell how how many of your search results fall in a certain price range or are members of a certain category.

This module allows you to perform these types of operations on the results of a database query via a DBIx::Class::ResultSet.

What about GROUP BY?

Using an SQL GROUP BY can do the same things that this module does. The reason I've created this module is to allow for more complex situations and to avoid generating more SQL queries. Large facet implementations that cover dozens of dimensions can quickly cause an SQL query to become unweildy. This module provides an alternate approach for people who may've run afoul of the aforementioned problems.



List of facets, keyed by name.



Add a facet to this faceter.


Performs the faceting, returning a DBIx::Class::ResultSet::Faceter::Result object.


Cory G Watson, <gphat at>


Jay Shirley


Copyright 2010 Cold Hard Code, LLC

This program is free software; you can redistribute it and/or modify it under the terms of either: the GNU General Public License as published by the Free Software Foundation; or the Artistic License.

See for more information.