Skip to content

Commit 8a69a3c

Browse files
author
Sam Kleinman
committed
edits: DOCS-675
1 parent c39d966 commit 8a69a3c

File tree

2 files changed

+27
-45
lines changed

2 files changed

+27
-45
lines changed

source/applications/read.txt

Lines changed: 15 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,7 @@ Consider the following examples that illustrate the use of the
135135
contribs: 'UNIX'
136136
}
137137
)
138-
138+
139139
- The following operation returns all documents in the ``bios``
140140
collection where ``awards`` array contains a subdocument element
141141
that contains the ``award`` field equal to ``'Turing Award'`` and the
@@ -374,7 +374,7 @@ variable:
374374

375375
.. code-block:: javascript
376376

377-
if (myDocument) {
377+
if (myDocument) {
378378

379379
var myName = myDocument.name;
380380

@@ -465,28 +465,21 @@ You can chain these cursor methods, as in the following examples [#dbquery-serve
465465
db.bios.find().sort( { name: 1 } ).limit( 5 )
466466
db.bios.find().limit( 5 ).sort( { name: 1 } )
467467

468-
See :ref:`JavaScript cursor methods <js-query-cursor-methods>` and your
469-
:doc:`driver </applications/drivers>` documentation for more
470-
information on cursor methods. See :ref:`read-operations-cursors` for
468+
See the :ref:`JavaScript cursor methods <js-query-cursor-methods>`
469+
reference and your :doc:`driver </applications/drivers>` documentation
470+
for additional references. See :ref:`read-operations-cursors` for
471471
more information regarding cursors.
472472

473-
.. [#dbquery-server] Regardless of the order you chain the :method:`limit()
474-
<cursor.limit()>` and the :method:`sort() <cursor.sort()>`, the
475-
request to the server has the following structure that treats the
476-
query and the :method:`sort() <cursor.sort()>` modifier as a single
477-
object:
478-
479-
.. code-block:: javascript
480-
481-
db.bios.find( { $query: {}, $orderby: { name: 1 } } ).limit( 5 )
482-
483-
This structure means that the :method:`limit() <cursor.limit()>`
484-
method is always applied after the :method:`sort() <cursor.sort()>`
485-
regardless of the order in which the client chains the two methods.
486-
487-
For other cursor modifiers that are sent with the
488-
query as a single object to the server, see the :doc:`meta query operators
489-
</reference/meta-query-operators>`.
473+
.. [#dbquery-server] Regardless of the order you chain the
474+
:method:`limit() <cursor.limit()>` and the :method:`sort()
475+
<cursor.sort()>`, the request to the server has the following
476+
structure that treats the query and the :method:`sort()
477+
<cursor.sort()>` modifier as a single object. Therefore, the
478+
:method:`limit() <cursor.limit()>` operation method is always
479+
applied after the :method:`sort() <cursor.sort()>` regardless of
480+
the specified order of the operations in the chain. See the
481+
:doc:`meta query operators </reference/meta-query-operators>` for
482+
more information.
490483

491484
.. _crud-read-findOne:
492485
.. _crud-read-find-one:

source/core/read-operations.txt

Lines changed: 12 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,6 @@ operators, refer to the :doc:`/applications/read` page of the
9797
wrapper for the more formal query structure with the
9898
:operator:`$query` operator.
9999

100-
101100
.. _read-operations-query-document:
102101
.. _read-operations-query-argument:
103102

@@ -669,7 +668,7 @@ Cursors
669668
The :method:`find() <db.collection.find()>` method returns a
670669
:term:`cursor` to the results; however, in the :program:`mongo` shell,
671670
if the returned cursor is not assigned to a variable, then the cursor
672-
is automatically iterated up to 20 times [#setShellBatchSize]_ to print
671+
is automatically iterated up to 20 times [#set-shell-batch-size]_ to print
673672
up to the first 20 documents that match the query, as in the following
674673
example:
675674

@@ -680,8 +679,8 @@ example:
680679
When you assign the :method:`find() <db.collection.find()>` to a
681680
variable:
682681

683-
- you can type the name of the cursor variable to iterate up to 20
684-
times [#setShellBatchSize]_ and print the matching documents, as in
682+
- you can call the cursor variable in the shell to iterate up to 20
683+
times [#set-shell-batch-size]_ and print the matching documents, as in
685684
the following example:
686685

687686
.. code-block:: javascript
@@ -696,25 +695,20 @@ variable:
696695
.. code-block:: javascript
697696

698697
var myCursor = db.inventory.find( { type: 'food' } );
699-
700698
var myDocument = myCursor.hasNext() ? myCursor.next() : null;
701699

702700
if (myDocument) {
703-
704701
var myItem = myDocument.item;
705-
706702
print(tojson(myItem));
707703
}
708704

709-
To print, you can also use the ``printjson()`` method instead of
710-
``print(tojson())``:
705+
As an alternative print operation, cosider the the ``printjson()``
706+
helper method to replace ``print(tojson())``:
711707

712708
.. code-block:: javascript
713709

714-
if (myDocument) {
715-
710+
if (myDocument) {
716711
var myItem = myDocument.item;
717-
718712
printjson(myItem);
719713
}
720714

@@ -732,13 +726,8 @@ See :ref:`JavaScript cursor methods <js-query-cursor-methods>` and your
732726
:doc:`driver </applications/drivers>` documentation for more
733727
information on cursor methods.
734728

735-
.. [#setShellBatchSize] You can use the ``DBQuery.shellBatchSize`` to
736-
change the number of iteration from the default value ``20``, as in the
737-
following example which sets the number to ``10``:
738-
739-
.. code-block:: javascript
740-
741-
DBQuery.shellBatchSize = 10
729+
.. [#set-shell-batch-size] You can use the ``DBQuery.shellBatchSize`` to
730+
change the number of iteration from the default value ``20``.
742731

743732
Iterator Index
744733
~~~~~~~~~~~~~~
@@ -788,11 +777,11 @@ Consider the following behaviors related to cursors:
788777
should either close the cursor manually or exhaust the cursor. In the
789778
:program:`mongo` shell, you can set the ``noTimeout`` flag
790779
[#queryOptions]_:
791-
792-
.. code-block:: javascript
793-
780+
781+
.. code-block:: javascript
782+
794783
var myCursor = db.inventory.find().addOption(DBQuery.Option.noTimeout);
795-
784+
796785
See your :doc:`driver </applications/drivers>` documentation for
797786
information on setting the ``noTimeout`` flag.
798787

0 commit comments

Comments
 (0)