@@ -20,8 +20,8 @@ Skip Returned Results
20
20
Overview
21
21
--------
22
22
23
- In this guide, you can learn how to use the {+driver-long+} to specify the
24
- number of documents to skip in a read operation .
23
+ In this guide, you can learn how to use the {+driver-long+} to perform a read
24
+ operation that skips a specified number of documents when returning results .
25
25
26
26
Sample Data for Examples
27
27
------------------------
@@ -44,12 +44,16 @@ collection:
44
44
:language: rust
45
45
:dedent:
46
46
47
- Skip
48
- ----
47
+ Skip Documents
48
+ --------------
49
49
50
- To skip results retrieved by a query, you can chain the ``skip()`` method to the
51
- ``find()`` method. Alternatively, if you are setting and reusing options for
52
- your query, you can use the ``skip()`` method of the ``FindOptions`` struct.
50
+ This section describes how to skip results retrieved by a query in the following ways:
51
+
52
+ - :ref:`skip() method <rust-skip-method>`: Chain the ``skip()`` method to the
53
+ ``find()`` method
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
53
57
54
58
If the number of skipped documents exceeds the number of matched documents for a
55
59
query, then that query returns no documents.
@@ -59,12 +63,18 @@ fields. To avoid skipping random documents, use the ``sort()`` method to sort
59
63
documents on a field with a unique value before setting a skip option. To learn
60
64
more, see the :ref:`rust-sort-guide` guide.
61
65
62
- Example
63
- ~~~~~~~
66
+ .. _rust-skip-method:
67
+
68
+ skip() Method Example
69
+ ~~~~~~~~~~~~~~~~~~~~~~
64
70
65
- The following example performs a ``find()`` operation with the following behavior:
71
+ 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
73
+ to the ``find()`` method to skip documents.
66
74
67
- - Sorts the results in ascending order on the ``author`` field
75
+ This example runs a ``find()`` operation that performs the following actions:
76
+
77
+ - Sorts the results in ascending order of their ``author`` field values
68
78
- Skips the first two documents
69
79
- Returns the remaining documents
70
80
@@ -84,12 +94,17 @@ The following example performs a ``find()`` operation with the following behavio
84
94
Book { name: "A Dance with Dragons", author: "Martin", length: 1104 }
85
95
Book { name: "Atlas Shrugged", author: "Rand", length: 1088 }
86
96
97
+ .. _rust-findoptions-skip:
98
+
87
99
Options Example
88
100
~~~~~~~~~~~~~~~
89
101
90
- Alternatively, you can use the ``skip()`` method of the ``FindOptions`` struct.
91
- The following example performs a ``find()`` operation with the following
92
- behavior:
102
+ Alternatively, you can set the ``skip`` field of the ``FindOptions`` struct by
103
+ using the ``skip()`` setter method. Then, chain the ``with_options()`` method to
104
+ the ``find()`` method and pass your ``FindOptions`` struct as a parameter to the
105
+ ``with_options()`` method.
106
+
107
+ This example runs a ``find()`` operation that performs the following actions:
93
108
94
109
- Sorts the results in descending order on the ``name`` field
95
110
- Skips the first document
@@ -113,16 +128,15 @@ behavior:
113
128
Book { name: "Atlas Shrugged", author: "Rand", length: 1088 }
114
129
115
130
Aggregation
116
- -----------
131
+ ~~~~~~~~~~~
117
132
118
133
You can use the ``$skip`` stage in an aggregation pipeline to skip documents. To
119
134
learn more, see the :ref:`rust-aggregation` guide.
120
135
121
136
Example
122
137
~~~~~~~
123
138
124
- The following example uses the ``aggregate()`` method to perform an aggregation
125
- operation with the following behavior:
139
+ This example runs an aggregation pipeline that performs the following actions:
126
140
127
141
- Sorts the results in ascending order on the ``author`` field
128
142
- Skips the first document
@@ -148,7 +162,7 @@ operation with the following behavior:
148
162
Additional Information
149
163
----------------------
150
164
151
- To learn more about the operations mentioned in this guide, see the following:
165
+ To learn more about the operations mentioned in this guide, see the following guides :
152
166
153
167
- :ref:`rust-query-guide`
154
168
- :ref:`rust-retrieve-guide`
@@ -161,7 +175,7 @@ API Documentation
161
175
~~~~~~~~~~~~~~~~~
162
176
163
177
To learn more about any of the methods or types discussed in this guide, see the
164
- following API Documentation :
178
+ following API documentation :
165
179
166
180
- `find() <{+api+}/struct.Collection.html#method.find>`__
167
181
- `FindOptions <{+api+}/options/struct.FindOptions.html>`__
0 commit comments