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

NAME

6       Mango::Cursor::Query - MongoDB query cursor
7

SYNOPSIS

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

DESCRIPTION

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

ATTRIBUTES

19       Mango::Cursor::Query inherits all attributes from Mango::Cursor and
20       implements the following new ones.
21
22   await_data
23         my $await = $cursor->await_data;
24         $cursor   = $cursor->await_data(1);
25
26       Await data.
27
28   comment
29         my $comment = $cursor->comment;
30         $cursor     = $cursor->comment('Fun query!');
31
32       A comment to identify query.
33
34   fields
35         my $fields = $cursor->fields;
36         $cursor    = $cursor->fields({foo => 1});
37
38       Select fields from documents.
39
40   hint
41         my $hint = $cursor->hint;
42         $cursor  = $cursor->hint({foo => 1});
43
44       Force a specific index to be used.
45
46   max_scan
47         my $max = $cursor->max_scan;
48         $cursor = $cursor->max_scan(500);
49
50       Limit the number of documents to scan.
51
52   max_time_ms
53         my $max = $cursor->max_time_ms;
54         $cursor = $cursor->max_time_ms(500);
55
56       Timeout for query in milliseconds.
57
58   query
59         my $query = $cursor->query;
60         $cursor   = $cursor->query({foo => 'bar'});
61
62       Original query.
63
64   read_preference
65         my $pref = $cursor->read_preference;
66         $cursor  = $cursor->read_preference({mode => 'SECONDARY'});
67
68       Read preference.
69
70   skip
71         my $skip = $cursor->skip;
72         $cursor  = $cursor->skip(5);
73
74       Number of documents to skip, defaults to 0.
75
76   snapshot
77         my $snapshot = $cursor->snapshot;
78         $cursor      = $cursor->snapshot(1);
79
80       Use snapshot mode.
81
82   sort
83         my $sort = $cursor->sort;
84         $cursor  = $cursor->sort({foo => 1});
85         $cursor  = $cursor->sort(bson_doc(foo => 1, bar => -1));
86
87       Sort documents, the order of keys matters.
88
89   tailable
90         my $tailable = $cursor->tailable;
91         $cursor      = $cursor->tailable(1);
92
93       Tailable cursor.
94

METHODS

96       Mango::Cursor::Query inherits all methods from Mango::Cursor and
97       implements the following new ones.
98
99   build_query
100         my $query = $cursor->build_query;
101         my $query = $cursor->build_query($explain);
102
103       Generate final query with cursor attributes.
104
105   clone
106         my $clone = $cursor->clone;
107
108       Clone cursor.
109
110   count
111         my $count = $cursor->count;
112
113       Count number of documents this cursor can return. You can also append a
114       callback to perform operation non-blocking.
115
116         $cursor->count(sub {
117           my ($cursor, $err, $count) = @_;
118           ...
119         });
120         Mojo::IOLoop->start unless Mojo::IOLoop->is_running;
121
122   distinct
123         my $values = $cursor->distinct('foo');
124
125       Get all distinct values for key. You can also append a callback to
126       perform operation non-blocking.
127
128         $cursor->distinct(foo => sub {
129           my ($cursor, $err, $values) = @_;
130           ...
131         });
132         Mojo::IOLoop->start unless Mojo::IOLoop->is_running;
133
134   explain
135         my $doc = $cursor->explain;
136
137       Provide information on the query plan. You can also append a callback
138       to perform operation non-blocking.
139
140         $cursor->explain(sub {
141           my ($cursor, $err, $doc) = @_;
142           ...
143         });
144         Mojo::IOLoop->start unless Mojo::IOLoop->is_running;
145

SEE ALSO

147       Mango, Mojolicious::Guides, <http://mojolicio.us>.
148
149
150
151perl v5.36.0                      2023-01-20           Mango::Cursor::Query(3)
Impressum