Hey all,
Wouldn't it be nice if the ResultSet iterators were a bit more advanced?

I would love it if the iterator built into DBIx::Class supported some more functional programming style methods.

ie. So that I could do:

$schema->resultset('Users')->search(
  { first_name => 'Bob' }
)->foreach(
  sub { email_user($_) }
);

Or to "map" to get the results I want in one hit:

my @uppercase_names = $schema->resultset('Users')->search(
  { first_name => 'Bob' }
)->map(
  sub { uc($_->last_name . $_->firstname)  }
);

Or do a more complex check, grep style, to filter the list:

my @y_users = $schema->resultset('Users')->search(
  { first_name => 'Bob' }
)->grep(
  sub { return complex_check($_)  }
);



I realise these examples are a bit contrived, and in some cases could be re-done with more complex SQL queries, but I thought I'd put the suggestion out there..

-Toby

_______________________________________________
List: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/dbix-class
IRC: irc.perl.org#dbix-class
SVN: http://dev.catalyst.perl.org/repos/bast/DBIx-Class/
Searchable Archive: http://www.grokbase.com/group/[email protected]

Reply via email to