Skip to content

Commit ffeff33

Browse files
committed
clean up aggregation section
1 parent a07877c commit ffeff33

File tree

2 files changed

+13
-10
lines changed
  • source
    • fundamentals/crud/read-operations
    • includes/fundamentals/code-snippets/crud

2 files changed

+13
-10
lines changed

source/fundamentals/crud/read-operations/skip.txt

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -52,8 +52,12 @@ This section describes how to skip results retrieved by a query in the following
5252
- :ref:`skip() method <rust-skip-method>`: Chain the ``skip()`` method to the
5353
``find()`` method
5454
- :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
5761

5862
If the number of skipped documents exceeds the number of matched documents for a
5963
query, then that query returns no documents.
@@ -69,7 +73,7 @@ skip() Method Example
6973
~~~~~~~~~~~~~~~~~~~~~~
7074

7175
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
7377
to the ``find()`` method to skip documents.
7478

7579
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:
99103
Options Example
100104
~~~~~~~~~~~~~~~
101105

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
103108
using the ``skip()`` setter method. Then, chain the ``with_options()`` method to
104109
the ``find()`` method and pass your ``FindOptions`` struct as a parameter to the
105110
``with_options()`` method.
@@ -127,15 +132,14 @@ This example runs a ``find()`` operation that performs the following actions:
127132
Book { name: "Les Misérables", author: "Hugo", length: 1462 }
128133
Book { name: "Atlas Shrugged", author: "Rand", length: 1088 }
129134

130-
Aggregation
131-
~~~~~~~~~~~
135+
.. _rust-aggregation-skip:
136+
137+
Aggregation Example
138+
~~~~~~~~~~~~~~~~~~~
132139

133140
You can use the ``$skip`` stage in an aggregation pipeline to skip documents. To
134141
learn more, see the :ref:`rust-aggregation` guide.
135142

136-
Example
137-
~~~~~~~
138-
139143
This example runs an aggregation pipeline that performs the following actions:
140144

141145
- Sorts the results in ascending order on the ``author`` field

source/includes/fundamentals/code-snippets/crud/skip.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,6 @@ async fn main() -> mongodb::error::Result<()> {
8484
// start-aggregation-example
8585
let pipeline = vec![
8686
doc! { "$match": {} },
87-
// 1 for ascending order, -1 for descending order
8887
doc! { "$sort": { "author": 1 } }
8988
doc! { "$skip": 1 },
9089
];

0 commit comments

Comments
 (0)