I would like to add that, instead of adding a 'search' method in My::Table
,
one can also enhance the ->search method provided by DBIx::Class::ResultSet
, like so:
package Schema::ResultSet::My::Table;
use base 'DBIx::Class::ResultSet';
sub search {
my ( $self, $args ) = ( shift, shift );
# do what you want here with the args passed to ->search
return $self->next::method( $args, @_ );
}
Also, you can very likely subclass ResultSet so you can provide this altered ( cached ) search to all ResultSets, thus keeping the caching code in one place for all tables,
which would be a lot less messy imho.
This I have not tested yet, though.
To make the above example work, put it in a file with the name of your schema class, in the directory "../Schema/ResultSet/"
, and make sure your Schema.pm contains "load_namespaces();"
which will nicely auto-load all your overloaded classes that you put there ( I think my Catalyst install did that automatically, but I do not recall ).
DBIx::Class::ResultSet