$c->model()->search( {}, {order_by=>???, page=>$page} )

How do we "order_by" a field from a related record when pulling a resultset?
We want to order users by team (then by lastname, firstname) and be able to
PAGE back and forth...

e.g. a User belongs_to a Team.

    my $team_name  = $c->user->team->name;

    my $users = $c->model('My::User')
        ->search_rs( {}, {
            order_by => {
                -asc => ???user->team->name???,  ###### howto?
                -asc => 'lastname',
                -asc => 'firstname',
            },
            page => $page,
        } );

We're wanting to order by team-name, then user-lastname, then
user-firstname.

Here's a perl sort AFTER we have the results:

    my $user_collection = [
        sort {
                $a->team->name cmp $b->team->name ||
                $a->lastname   cmp $b->lastname   ||
                $a->firstname  cmp $b->firstname
                }
            $users->all
    ];

But this approach doesn't allow for paging backward and forward over the
list...?

-- 
will trillich
"I think it would be worse to expect nothing than to be disappointed." --
Anne (with an 'e') Shirley
_______________________________________________
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/

Reply via email to