Skip site navigation (1)Skip section navigation (2)

FreeBSD Manual Pages

  
 
  

home | help
Mango::Cursor(3)      User Contributed Perl Documentation     Mango::Cursor(3)

NAME
       Mango::Cursor - MongoDB cursor

SYNOPSIS
	 use Mango::Cursor;

	 my $cursor = Mango::Cursor->new(collection => $collection);
	 my $docs   = $cursor->all;

DESCRIPTION
       Mango::Cursor is	a container for	MongoDB	cursors	used by
       Mango::Collection.

ATTRIBUTES
       Mango::Cursor implements	the following attributes.

   batch_size
	 my $size = $cursor->batch_size;
	 $cursor  = $cursor->batch_size(10);

       Number of documents to fetch in one batch, defaults to 0.

   collection
	 my $collection	= $cursor->collection;
	 $cursor	= $cursor->collection(Mango::Collection->new);

       Mango::Collection object	this cursor belongs to.

   id
	 my $id	 = $cursor->id;
	 $cursor = $cursor->id(123456);

       Cursor id.

   limit
	 my $limit = $cursor->limit;
	 $cursor   = $cursor->limit(10);

       Limit the number	of documents, defaults to 0.

METHODS
       Mango::Cursor inherits all methods from Mojo::Base and implements the
       following new ones.

   add_batch
	 $cursor = $cursor->add_batch($docs);

       Add batch of documents to cursor.

   all
	 my $docs = $cursor->all;

       Fetch all documents at once. 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;

   next
	 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;

   rewind
	 $cursor->rewind;

       Rewind cursor and kill it on the	server.	You can	also append a callback
       to perform operation non-blocking.

	 $cursor->rewind(sub {
	   my ($cursor,	$err) =	@_;
	   ...
	 });
	 Mojo::IOLoop->start unless Mojo::IOLoop->is_running;

   num_to_return
	 my $num = $cursor->num_to_return;

       Number of results to return with	next "QUERY" or	"GET_MORE" operation
       based on	"batch_size" and "limit".

SEE ALSO
       Mango, Mojolicious::Guides, <http://mojolicio.us>.

perl v5.24.1			  2015-12-02		      Mango::Cursor(3)

NAME | SYNOPSIS | DESCRIPTION | ATTRIBUTES | METHODS | SEE ALSO

Want to link to this manual page? Use this URL:
<https://www.freebsd.org/cgi/man.cgi?query=Mango::Cursor&sektion=3&manpath=FreeBSD+12.1-RELEASE+and+Ports>

home | help