1Mango::Cursor(3)      User Contributed Perl Documentation     Mango::Cursor(3)
2
3
4

NAME

6       Mango::Cursor - MongoDB cursor
7

SYNOPSIS

9         use Mango::Cursor;
10
11         my $cursor = Mango::Cursor->new(collection => $collection);
12         my $docs   = $cursor->all;
13

DESCRIPTION

15       Mango::Cursor is a container for MongoDB cursors used by
16       Mango::Collection.
17

ATTRIBUTES

19       Mango::Cursor implements the following attributes.
20
21   batch_size
22         my $size = $cursor->batch_size;
23         $cursor  = $cursor->batch_size(10);
24
25       Number of documents to fetch in one batch, defaults to 0.
26
27   collection
28         my $collection = $cursor->collection;
29         $cursor        = $cursor->collection(Mango::Collection->new);
30
31       Mango::Collection object this cursor belongs to.
32
33   id
34         my $id  = $cursor->id;
35         $cursor = $cursor->id(123456);
36
37       Cursor id.
38
39   limit
40         my $limit = $cursor->limit;
41         $cursor   = $cursor->limit(10);
42
43       Limit the number of documents, defaults to 0.
44

METHODS

46       Mango::Cursor inherits all methods from Mojo::Base and implements the
47       following new ones.
48
49   add_batch
50         $cursor = $cursor->add_batch($docs);
51
52       Add batch of documents to cursor.
53
54   all
55         my $docs = $cursor->all;
56
57       Fetch all documents at once. You can also append a callback to perform
58       operation non-blocking.
59
60         $cursor->all(sub {
61           my ($cursor, $err, $docs) = @_;
62           ...
63         });
64         Mojo::IOLoop->start unless Mojo::IOLoop->is_running;
65
66   next
67         my $doc = $cursor->next;
68
69       Fetch next document. You can also append a callback to perform
70       operation non-blocking.
71
72         $cursor->next(sub {
73           my ($cursor, $err, $doc) = @_;
74           ...
75         });
76         Mojo::IOLoop->start unless Mojo::IOLoop->is_running;
77
78   rewind
79         $cursor->rewind;
80
81       Rewind cursor and kill it on the server. You can also append a callback
82       to perform operation non-blocking.
83
84         $cursor->rewind(sub {
85           my ($cursor, $err) = @_;
86           ...
87         });
88         Mojo::IOLoop->start unless Mojo::IOLoop->is_running;
89
90   num_to_return
91         my $num = $cursor->num_to_return;
92
93       Number of results to return with next "QUERY" or "GET_MORE" operation
94       based on "batch_size" and "limit".
95

SEE ALSO

97       Mango, Mojolicious::Guides, <http://mojolicio.us>.
98
99
100
101perl v5.34.0                      2021-07-22                  Mango::Cursor(3)
Impressum