GSP
Quick Navigator

Search Site

Unix VPS
A - Starter
B - Basic
C - Preferred
D - Commercial
MPS - Dedicated
Previous VPSs
* Sign Up! *

Support
Contact Us
Online Help
Handbooks
Domain Status
Man Pages

FAQ
Virtual Servers
Pricing
Billing
Technical

Network
Facilities
Connectivity
Topology Map

Miscellaneous
Server Agreement
Year 2038
Credits
 

USA Flag

 

 

Man Pages
Mango::Cursor(3) User Contributed Perl Documentation Mango::Cursor(3)

Mango::Cursor - MongoDB cursor

  use Mango::Cursor;

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

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

Number of documents to fetch in one batch, defaults to 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 the number of documents, defaults to 0.

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

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

Add batch of documents to cursor.

  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;

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

  my $num = $cursor->num_to_return;

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

Mango, Mojolicious::Guides, <http://mojolicio.us>.
2018-03-17 perl v5.32.1

Search for    or go to Top of page |  Section 3 |  Main Index

Powered by GSP Visit the GSP FreeBSD Man Page Interface.
Output converted with ManDoc.