NAME

Mongol::Roles::Pagination - Pagination for Mongol models

SYNOPSIS

use POSIX qw( ceil );
use Data::Dumper;

my $page = Models::Person->paginate( { age => { '$gt' => 25 } }, 0, 10 );

my $total_pages = ceil( $page->total() / $page->rows() );
my $current_page = ( $page->start() / $page->rows() ) + 1;

printf( "%s", Dumper( $page->serialize() ) );

DESCRIPTION

METHODS

paginate

my $page = Models::Person->paginate( { first_name => 'John' }, 0, 10, {} );

SEE ALSO