Beefy Boxes and Bandwidth Generously Provided by pair Networks
There's more than one way to do things
 
PerlMonks  

Filtering DBIx::Class resultsets with external criteria

by Ovid (Cardinal)
on Nov 07, 2008 at 09:06 UTC ( #722180=perlquestion: print w/ replies, xml ) Need Help??
Ovid has asked for the wisdom of the Perl Monks concerning the following question:

Using DBIx::Class and I have a resultset which needs to be filtered by data which cannot be generated by SQL. What I need to do is something effectively equivalent to this hypothetical example:

my $resultset = $schema->resultset('Service')->search(\%search +); my $new_resultset = $resultset->filter( sub { my $web_service = shift; return $web_service->is_available; } );

Reading through the docs gives me no clue how to accomplish a strategy like this.

Comment on Filtering DBIx::Class resultsets with external criteria
Download Code
Re: Filtering DBIx::Class resultsets with external criteria
by arc_of_descent (Hermit) on Nov 09, 2008 at 04:46 UTC
    Can't you just do something like this:
    my $resultset = grep { WS->new($_->id)->is_available; } $schema->resultset('Service')->search(\%search);
    update
    Not sure of how $web_service is linked to your app. I guess I'm trying to say that I utilize grep for simple filters.

    --
    Rohan

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://722180]
Approved by Arunbear
Front-paged by grinder
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others rifling through the Monastery: (13)
As of 2014-10-22 14:11 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    For retirement, I am banking on:










    Results (118 votes), past polls