Mango::Cursor - MongoDB cursor
use Mango::Cursor; my $cursor = Mango::Cursor->new(collection => $collection);
Mango::Cursor is a container for MongoDB cursors used by Mango::Collection.
Mango::Cursor implements the following attributes.
my $size = $cursor->batch_size; $cursor = $cursor->batch_size(10);
Batch size, defaults to 0.
0
my $collection = $cursor->collection; $cursor = $cursor->collection(Mango::Collection->new);
Mango::Collection object this cursor belongs to.
my $id = $cursor->id; $cursor = $cursor->id(123456);
Cursor id.
my $limit = $cursor->limit; $cursor = $cursor->limit(10);
Limit, defaults to 0.
my $fields = $cursor->fields; $cursor = $cursor->fields({foo => 1});
Fields.
my $query = $cursor->query; $cursor = $cursor->query({foo => 'bar'});
Query.
my $skip = $cursor->skip; $cursor = $cursor->skip(5);
Documents to skip, defaults to 0.
my $sort = $cursor->sort; $cursor = $cursor->sort({foo => 1});
Sort.
Mango::Cursor inherits all methods from Mojo::Base and implements the following new ones.
my $docs = $cursor->all;
Fetch all documents. You can also append a callback to perform operation non-blocking.
$cursor->all(sub { my ($cursor, $err, $docs) = @_; ... }); Mojo::IOLoop->start unless Mojo::IOLoop->is_running;
my $count = $cursor->count;
Count number of documents this cursor can return. You can also append a callback to perform operation non-blocking.
$cursor->count(sub { my ($cursor, $err, $count) = @_; ... }); Mojo::IOLoop->start unless Mojo::IOLoop->is_running;
my $doc = $cursor->next;
Fetch next document. You can also append a callback to perform operation non-blocking.
$cursor->next(sub { my ($cursor, $err, $doc) = @_; ... }); Mojo::IOLoop->start unless Mojo::IOLoop->is_running;
$cursor->rewind;
Rewind cursor. You can also append a callback to perform operation non-blocking.
$cursor->rewind(sub { my $cursor = shift; ... }); Mojo::IOLoop->start unless Mojo::IOLoop->is_running;
Mango, Mojolicious::Guides, http://mojolicio.us.
To install Mango, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Mango
CPAN shell
perl -MCPAN -e shell install Mango
For more information on module installation, please visit the detailed CPAN module installation guide.