Any input/comments on best practices for extending a DBIC model? I have a
DBIC schema that for the most part does what I need it to do. I find where I
need model specific enhancements I can easily extend the schema objects
themselves keeping the data centric code out of my controller layer. What
I'm struggling with is how best to handle things at a higher level - i.e.
modifying the resultsets themselves.
e.g. say I have a Clients table and I want to get *all* clients in the
system and then massage them in some way. I cannot do this with simple SQL
or DBIC joins. I can extend Clients.pm for level stuff but what I really
need is a way to extend the DBIx::Class::ResultSet object that is returned
by $c->model('DB::Clients') so that that I can perform something like the
following:
my @clients = $c->model('DB::Clients')->grouped_clients;
I'm using Catalyst::Model::DBIC::Schema. Is there a preferred way to hook
into the result set to customize things the way I need?
Or do I just create a new model altogether and call the schema from that
model?
my @clients = $c->model('MyNewModel')->grouped_clients;
I dunno. The second method just seems a little kludgey to me unless I make
it a complete wrapper around my DBIC schema. Any insight into how you guys
build your apps would be most appreciated.
Thanks!
Eric
_______________________________________________
List: [email protected]
Listinfo: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/catalyst
Searchable archive: http://www.mail-archive.com/[email protected]/
Dev site: http://dev.catalyst.perl.org/