[Dbix-class] DynamicColumns
Patrick Meidl
patrick at pantheon.at
Tue Sep 18 06:58:52 GMT 2012
On Mon, Sep 17 2012, Karl Forner <karl.forner at gmail.com> wrote:
> The goal is to provide dynamic columns to dbix result objects.
[...]
> To be more concrete, suppose that you have User table, with a foreign
> key user_type_id on a UserType table (a lookup table).
> You'd like your nice extjs grid automatically filled thanks to
> CatalystX::ExtJS::REST to display a user_type column, because the
> "user_type_id" column is not veru useful for your customers.
>
> Using DBICx::DynamicColumns, you could tie the (new) method/column "type"
> to $row->user_type()->name() for instance.
isn't that exactly what you do with the 'proxy' attribute? see
https://metacpan.org/module/DBIx::Class::Relationship::Base#attributes
so in your User table, you would define the relationship like this:
--8<-------------------------------------------------------------------
__PACKAGE__->belongs_to(
"user_type",
"Your::Schema::Result::UserType",
{ user_type_id => "user_type_id" },
{
proxy => {
type => 'name',
},
},
);
--8<-------------------------------------------------------------------
not sure though about your other intentions with the dynamic columns
class.
patrick
--
Patrick Meidl ........................ patrick at pantheon.at
Vienna, Austria ...................... http://gplus.to/pmeidl
More information about the DBIx-Class
mailing list