Filtering results obtained from manager->get_objects

9 views
Skip to first unread message

Ryatt

unread,
May 5, 2016, 11:18:40 AM5/5/16
to Rose::DB::Object
Hi,

Is there a way to filter the objects returned by manager->get_objects further using a similar hash structure as an argument as needed by get_objects?

my $all_objs = $manager->get_objects(user_id => $user_id);

What I want:
my ($obj_1) = $manager->filter_objects($all_objs, {query => ['type' => 'obj_1'], sort => 'order', limit => 1}); # preventing another SQL query

What's working:
my $obj_1 = [ sort { $a->order <=> $b->order } grep $_->type eq 'obj_1', @$all_objs ]->[0];

For simple examples it works, but it get complicated when you try to apply limit, sort etc.

Thanks

Reply all
Reply to author
Forward
0 new messages