Skip to content

Commit 2327ffc

Browse files
committed
DOCS-689 incorporate feedback from mike and ed
1 parent a8f3805 commit 2327ffc

File tree

4 files changed

+43
-25
lines changed

4 files changed

+43
-25
lines changed

source/core/object-id.txt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -39,9 +39,9 @@ information on MongoDB's document orientation.
3939
ObjectId()
4040
----------
4141

42-
The :program:`mongo` shell provides the ``ObjectId()`` wrapper class
43-
to generate can generate a new ObjectId, and to provide the following
44-
helper attribute and methods:
42+
The :program:`mongo` shell provides the ``ObjectId()`` wrapper class to
43+
generate a new ObjectId, and to provide the following helper attribute
44+
and methods:
4545

4646
- ``str``
4747

source/core/read-operations.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -702,7 +702,7 @@ variable:
702702
print(tojson(myItem));
703703
}
704704

705-
As an alternative print operation, consider the the ``printjson()``
705+
As an alternative print operation, consider the ``printjson()``
706706
helper method to replace ``print(tojson())``:
707707

708708
.. code-block:: javascript

source/mongo.txt

Lines changed: 32 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,9 @@ Using the ``mongo`` Shell
44

55
.. default-domain:: mongodb
66

7-
:program:`mongo` shell is the MongoDB interactive shell and is part of
7+
The :program:`mongo` shell is the MongoDB interactive shell and is part of
88
the `MongoDB distribution <http://www.mongodb.org/downloads>`_. The
9-
:program:`mongo` is located in the ``<mongodb installation dir>/bin``
9+
:program:`mongo` program is located in the ``<mongodb installation dir>/bin``
1010
directory.
1111

1212
The :program:`mongo` shell is a JavaScript shell [#spider-monkey]_ from
@@ -62,9 +62,9 @@ To start the :program:`mongo` shell and connect to your :doc:`MongoDB
6262

6363
use myDatabase
6464

65-
See :ref:`mongo-shell-help-db` to list the available databases. See also
66-
:ref:`mongo-shell-getSiblingDB` to access a different
67-
database from the current database.
65+
To list the available database, use the command ``show dbs``. See
66+
also :ref:`mongo-shell-getSiblingDB` to access a different database
67+
from the current database.
6868

6969
To start the :program:`mongo` shell with other options, see
7070
:ref:`examples of starting up mongo <mongo-usage-examples>` and
@@ -103,12 +103,14 @@ From the :program:`mongo` shell, you can use the :doc:`shell methods
103103

104104
If the :program:`mongo` shell does not accept the name of the
105105
collection, for instance if the name contains a space or starts with
106-
a number, use an alternate syntax to refer to the collection, as in
107-
the following:
106+
a number, you can use an alternate syntax to refer to the
107+
collection, as in the following alternates:
108108

109109
.. code-block:: javascript
110110

111-
db['3test'].find()
111+
db["3test"].find()
112+
113+
db.getCollection("3test").find()
112114

113115
- The :method:`find() <db.collection.find()>` method is the JavaScript
114116
method to retrieve documents from ``myCollection``. The
@@ -119,9 +121,9 @@ From the :program:`mongo` shell, you can use the :doc:`shell methods
119121
first 20 documents that match the query. The :program:`mongo` shell
120122
will prompt ``Type it`` to iterate another 20 times.
121123

122-
You can use the ``DBQuery.shellBatchSize`` to change the number of
123-
iteration from the default value ``20``, as in the following example
124-
which sets it to ``10``:
124+
You can use the ``DBQuery.shellBatchSize`` variable to change the
125+
number of iteration from the default value ``20``, as in the
126+
following example which sets it to ``10``:
125127

126128
.. code-block:: javascript
127129

@@ -158,8 +160,8 @@ Print
158160

159161
The :program:`mongo` shell automatically prints the results of the
160162
:method:`find() <db.collection.find()>` method if the returned cursor
161-
is not assigned to a variable. To format the result as :term:`JSON`, you can
162-
add the ``.pretty()`` to the operation, as in the following:
163+
is not assigned to a variable. To format the result, you can add the
164+
``.pretty()`` to the operation, as in the following:
163165

164166
.. code-block:: javascript
165167

@@ -426,6 +428,22 @@ JavaScript methods to handle the cursor returned from the
426428

427429
db.collection.find().toArray
428430

431+
Some useful methods for handling cursors are:
432+
433+
- :method:`hasNext() <cursor.hasNext()>` which checks whether the
434+
cursor has more documents to return.
435+
436+
- :method:`next() <cursor.next()>` which returns the next document and
437+
moves by one the position of the cursor.
438+
439+
- :method:`forEach(\<function\>) <cursor.forEach()>` which iterates the
440+
whole cursor and applies the ``<function>`` to each document returned
441+
by the cursor.
442+
443+
For examples on iterating a cursor and retrieving the documents from
444+
the cursor, see :ref:`cursor handling <read-operations-cursors>`. See
445+
also :ref:`js-query-cursor-methods` for all available cursor methods.
446+
429447
.. _mongo-shell-tips:
430448

431449
Tips
@@ -615,7 +633,7 @@ instantiate database connections using the ``Mongo()`` constructor:
615633
new Mongo(<host:port>)
616634

617635
Consider the following example that instantiates a new connection to
618-
the MongoDB instance running on localhost on the default port and set
636+
the MongoDB instance running on localhost on the default port and sets
619637
the current ``db`` to ``myDatabase``:
620638

621639
.. code-block:: javascript

source/reference/mongo-shell-reference.txt

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ Basic Shell Javascript Operations
100100
----------------------------------
101101

102102
The :program:`mongo` shell provides numerous
103-
:doc:`/reference/javascript` for database operations.
103+
:doc:`/reference/javascript` methods for database operations.
104104

105105
In the :program:`mongo` shell, ``db`` is the variable that references
106106
the current database. The variable is automatically set to the default
@@ -299,21 +299,21 @@ The following table provides some common read operations in the
299299
* - :method:`db.collection.find( \<query\> ).count() <cursor.count()>`
300300

301301
- Returns the total number of objects that match the query.
302-
302+
303303
The :method:`<cursor.count()>` ignores :method:`limit()
304304
<cursor.limit()>` and :method:`skip() <cursor.skip()>`. For
305305
example, if 100 records match but the limit is 10,
306306
:method:`count() <cursor.count()>` will return 100. This will be
307307
faster than iterating yourself, but still take time.
308308

309309
* - :method:`db.collection.findOne( \<query\> ) <db.collection.findOne()>`
310-
310+
311311
- Find and return a single object. Returns null if not found.
312-
313-
The following example selects a single documents in the
312+
313+
The following example selects a single document in the
314314
``users`` collection with the ``name`` field matches to
315315
``"Joe"``:
316-
316+
317317
.. code-block:: javascript
318318

319319
coll = db.users;
@@ -439,7 +439,7 @@ opening new connections from the :program:`mongo` shell.
439439
Miscellaneous
440440
-------------
441441

442-
The following table displays some miscellaneous method:
442+
The following table displays some miscellaneous methods:
443443

444444
.. list-table::
445445
:header-rows: 1

0 commit comments

Comments
 (0)