Created
September 13, 2009 01:40
-
-
Save arodland/186042 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
my $books = $schema->resultset('Books'); # Knows how to find every book. | |
# Knows how to find books published in the 90s. | |
my $nineties_books = $schema->search({ | |
published => { -between => [1990, 1999] } | |
}); | |
# Knows how to find books published in the 90s that | |
# were awesome -- see how the state keeps getting added to? | |
my $awesome_nineties_books = $nineties_books->search({ | |
awesome => 'yes' | |
}); | |
# Knows how to find the top ten most awesome 90s books. | |
my $top10 = $awesome_nineties_books->search( | |
undef, | |
{ order_by => { -desc => "awesomeness" } } | |
)->slice(0, 9); | |
# *now* we actually do a DB query for the first time | |
my @top_ten_books = $top10->all; | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment