@@ -52,8 +52,12 @@ This section describes how to skip results retrieved by a query in the following
52
52
- :ref:`skip() method <rust-skip-method>`: Chain the ``skip()`` method to the
53
53
``find()`` method
54
54
- :ref:`FindOptions::skip() method <rust-findoptions-skip>`: Use the ``skip()``
55
- method of the ``FindOptions`` struct if you are setting and reusing options
56
- for your query
55
+ method of the ``FindOptions`` struct
56
+
57
+ Alternatively, you can :ref:`skip documents in an aggregation pipeline
58
+ <rust-aggregation-skip>`.
59
+
60
+ When you skip documents, the driver omits the specified number of documents from
57
61
58
62
If the number of skipped documents exceeds the number of matched documents for a
59
63
query, then that query returns no documents.
@@ -69,7 +73,7 @@ skip() Method Example
69
73
~~~~~~~~~~~~~~~~~~~~~~
70
74
71
75
The ``skip()`` method takes an integer that specifies the number of documents to
72
- omit from the beginning of the result set. You can chain the ``skip()`` method
76
+ omit from the beginning of the result set. Chain the ``skip()`` method
73
77
to the ``find()`` method to skip documents.
74
78
75
79
This example runs a ``find()`` operation that performs the following actions:
@@ -99,7 +103,8 @@ This example runs a ``find()`` operation that performs the following actions:
99
103
Options Example
100
104
~~~~~~~~~~~~~~~
101
105
102
- Alternatively, you can set the ``skip`` field of the ``FindOptions`` struct by
106
+ Alternatively, if you are setting and reusing options for your query, you can
107
+ use ``FindOptions``. Set the ``skip`` field of the ``FindOptions`` struct by
103
108
using the ``skip()`` setter method. Then, chain the ``with_options()`` method to
104
109
the ``find()`` method and pass your ``FindOptions`` struct as a parameter to the
105
110
``with_options()`` method.
@@ -127,15 +132,14 @@ This example runs a ``find()`` operation that performs the following actions:
127
132
Book { name: "Les Misérables", author: "Hugo", length: 1462 }
128
133
Book { name: "Atlas Shrugged", author: "Rand", length: 1088 }
129
134
130
- Aggregation
131
- ~~~~~~~~~~~
135
+ .. _rust-aggregation-skip:
136
+
137
+ Aggregation Example
138
+ ~~~~~~~~~~~~~~~~~~~
132
139
133
140
You can use the ``$skip`` stage in an aggregation pipeline to skip documents. To
134
141
learn more, see the :ref:`rust-aggregation` guide.
135
142
136
- Example
137
- ~~~~~~~
138
-
139
143
This example runs an aggregation pipeline that performs the following actions:
140
144
141
145
- Sorts the results in ascending order on the ``author`` field
0 commit comments