Skip to content

Commit 0e1b9fe

Browse files
committed
MM review
1 parent 31db930 commit 0e1b9fe

File tree

1 file changed

+16
-29
lines changed

1 file changed

+16
-29
lines changed

source/crud/query/specify-return-documents.txt

Lines changed: 16 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ in the ``courses`` collection:
4040
:dedent:
4141

4242
To run the examples in this guide, load the sample data into the
43-
``db.courses`` collection with the following snippet:
43+
``db.courses`` collection by using the following snippet:
4444

4545
.. literalinclude:: /includes/fundamentals/code-snippets/CRUD/sort.go
4646
:language: go
@@ -50,7 +50,7 @@ To run the examples in this guide, load the sample data into the
5050

5151
.. include:: /includes/fundamentals/automatic-db-coll-creation.rst
5252

53-
Each document contains a description of a university course that
53+
Each document represents a description of a university course and
5454
includes the course title and maximum enrollment, corresponding to
5555
the ``title`` and ``enrollment`` fields in each document.
5656

@@ -62,7 +62,7 @@ Sort
6262
To specify the order of your results, pass an interface specifying the
6363
sort fields and direction to the ``SetSort()`` method of an operation's options.
6464

65-
The following operations take options as a parameter:
65+
The following operations take ``SetSort()`` as an option:
6666

6767
- ``Find()``
6868
- ``FindOne()``
@@ -229,7 +229,7 @@ Aggregation
229229
~~~~~~~~~~~
230230

231231
You can also include the :manual:`$sort </reference/operator/aggregation/sort/>`
232-
stage to specify a sort in an aggregation pipeline.
232+
stage to specify a sort in an aggregation pipeline.
233233

234234
Example
235235
```````
@@ -277,7 +277,7 @@ To skip a specified number of returned results from a query, pass the
277277
number of documents you want to skip to the ``SetSkip()`` method of
278278
the read operation's options.
279279

280-
The following read operations take an options object as a parameter:
280+
The following read operations take ``SetSkip()`` as an option:
281281

282282
- ``Find()``
283283
- ``FindOne()``
@@ -287,11 +287,6 @@ The following read operations take an options object as a parameter:
287287
If the number of documents exceeds the number of matched documents for a
288288
query, that query returns no documents.
289289

290-
.. tip::
291-
292-
Passing in a negative number to the ``SetSkip()`` method results
293-
in a runtime error.
294-
295290
Find operations return documents in a natural order that is not sorted
296291
on any field. To avoid skipping random documents, use the ``SetSort()``
297292
method to sort documents on a field with unique values before setting a
@@ -383,7 +378,7 @@ To limit the number of documents returned from a query, pass the
383378
number of documents you want returned to the ``SetLimit()`` method of
384379
the read operation's options.
385380

386-
The following read operations take an options object as a parameter:
381+
The following read operations take ``SetLimit()`` as an option:
387382

388383
- ``Find()``
389384
- ``CountDocuments()``
@@ -429,7 +424,14 @@ Multiple Options
429424
~~~~~~~~~~~~~~~~
430425

431426
The driver performs the limit behavior last regardless of the order in which you set
432-
any other options.
427+
any other options. For example, the following option configurations produce the same
428+
result, regardless of the order in which ``SetLimit()`` is called:
429+
430+
.. code-block:: go
431+
:copyable: false
432+
433+
opts := options.Find().SetSort(bson.D{{"enrollment", -1}}).SetSkip(1).SetLimit(2)
434+
opts := options.Find().SetLimit(2).SetSort(bson.D{{"enrollment", -1}}).SetSkip(1)
433435

434436
The following example performs a ``Find()`` operation with the following behavior:
435437

@@ -464,19 +466,6 @@ The following example performs a ``Find()`` operation with the following behavio
464466
{"title":"Abstract Algebra","enrollment":60}
465467
{"title":"Plate Tectonics","enrollment":35}
466468

467-
.. tip::
468-
469-
Using any of the following option configurations also produces the same result:
470-
471-
.. code-block:: go
472-
:copyable: false
473-
474-
opts := options.Find().SetSort(bson.D{{"enrollment", -1}}).SetSkip(1).SetLimit(2)
475-
opts := options.Find().SetLimit(2).SetSort(bson.D{{"enrollment", -1}}).SetSkip(1)
476-
opts := options.Find().SetLimit(2).SetSkip(1).SetSort(bson.D{{"enrollment", -1}})
477-
opts := options.Find().SetSkip(1).SetSort(bson.D{{"enrollment", -1}}).SetLimit(2)
478-
opts := options.Find().SetSkip(1).SetLimit(2).SetSort(bson.D{{"enrollment", -1}})
479-
480469
.. _golang-limit-aggregation:
481470

482471
Aggregation
@@ -521,14 +510,12 @@ The following example shows how to return three documents:
521510
Additional Information
522511
----------------------
523512

524-
To learn more about the operations mentioned, see the following
525-
guides:
513+
To learn more about the operations discussed in this guide, see the following
514+
documentation:
526515

527516
- :ref:`golang-query-document`
528517
- :ref:`golang-retrieve`
529518
- :ref:`golang-compound-operations`
530-
- :ref:`golang-sort-results`
531-
- :ref:`golang-skip`
532519
- :ref:`golang-aggregation`
533520

534521
To learn about sorting text scores from your text search, see :ref:`golang-search-text`.

0 commit comments

Comments
 (0)