Skip to content

Commit 3d8d317

Browse files
author
Sam Kleinman
committed
editing: commands and other minor tweaks
1 parent 518ca97 commit 3d8d317

File tree

3 files changed

+102
-64
lines changed

3 files changed

+102
-64
lines changed

source/reference/collection-statistics.rst

Lines changed: 22 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ You may also use the literal command format:
2222
db.runCommand( { collStats: "collection" } )
2323
2424
Replace "``collection``" in both examples with the name of the
25-
colection you want statstics for. By default, the return values will
25+
collection you want statistics for. By default, the return values will
2626
appear in terms of bytes. You can, however, enter a scaling
2727
factor. For example, you can convert the return values to kilobytes
2828
like so: ::
@@ -37,7 +37,8 @@ Or:
3737
3838
db.runCommand( { collStats: "collection", scale: 1024 } )
3939
40-
See :dbcommand:`colStats` for
40+
.. seealso:: The documentation of the ":dbcommand:`collStats`" command
41+
and the ":js:func:`stats()`," method in the :doc:`mongo shell </mongo>`.
4142

4243
Fields
4344
------
@@ -49,24 +50,24 @@ Fields
4950

5051
.. stats:: count
5152

52-
The number of objects or documents in this colection.
53+
The number of objects or documents in this collection.
5354

5455
.. stats:: size
5556

56-
The size of the collection. This value is affected by the
57-
"``scale``" factor.
57+
The size of the collection. The "``scale``" factor affects this
58+
value.
59+
5860

5961
.. stats:: avgObjSize
6062

61-
The average size of an object in the collection. This value is
62-
affected by the "``scale``" factor.
63+
The average size of an object in the collection. The "``scale``"
64+
factor affects this value.
6365

6466
.. stats:: storageSize
6567

6668
The total amount of storage size. This is equal to the total number
67-
of extents allocated by this collection. This
68-
value is affected by the "``scale``" factor and the :term:`padding
69-
factor`.
69+
of extents allocated by this collection. The "``scale``" factor affects this
70+
value.
7071

7172
.. stats:: numExtents
7273

@@ -79,27 +80,28 @@ Fields
7980

8081
.. stats:: lastExtentSize
8182

82-
The size of the last extent allocated. This value is affected by
83-
the "``scale``" factor.
83+
The size of the last extent allocated. The "``scale``" factor affects this
84+
value.
8485

8586
.. stats:: paddingFactor
8687

87-
The amount of space added to the end of each document at insert time.
88-
This padding factor is calculated automatically by the server and exists
89-
to prevent excessive document relocations.
88+
The amount of space added to the end of each document at insert
89+
time. The server automatically calculates this padding factor,
90+
which exists to prevent excessive document relocations.
9091

9192
.. stats:: flags
9293

9394
"flags" : 1,
9495

95-
TODO what are flags in collection stats.
96+
TODO what are flags in collectionstats.
97+
9698

9799
.. stats:: totalIndexSize
98100

99-
The total size of all indexes. This value is affected by the "``scale``" factor.
101+
The total size of all indexes. The "``scale``" factor affects this
102+
value.
100103

101104
.. stats:: indexSizes
102105

103-
This field specifies the key and size
104-
of every existing index on the collection. This value is affected
105-
by the "``scale``" factor.
106+
This field specifies the key and size of every existing index on
107+
the collection. The "``scale``" factor affects this value.

source/reference/commands.rst

Lines changed: 78 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -6,25 +6,34 @@ Command Reference
66
.. highlight:: javascript
77

88
This document contains a reference to all :term:`database commands
9-
<database command>`. All commands are constructed using :term:`BSON`
10-
documents issued as queries against a special MongoDB
11-
collection named :term:`$cmd`. The JavaScript shell
12-
(i.e. :option:`mongo`,) provides the following syntax to facilitate
13-
running commands: ::
9+
<database command>`. MongoDB constructs commands using :term:`BSON`
10+
documents issued as queries against a special MongoDB collection named
11+
:term:`$cmd`. The JavaScript shell (i.e. :option:`mongo`,) provides
12+
the following syntax to facilitate running commands:
13+
14+
.. code-block:: javascript
1415
1516
db.runCommand( { <commandname>: <value> [, options] } );
1617
1718
Similarly, you can run administrative commands using the following
18-
syntax: ::
19+
syntax:
20+
21+
.. code-block:: javascript
22+
23+
db._adminCommand( { <commandname>: <value> [, options] } )
1924
20-
db._adminCommand( { <commandname>: <value> [, options] } );
25+
The ``_adminCommand`` helper is shorthand for the following JavaScript
26+
operation:
2127

22-
The ``_adminCommand`` helper is shorthand for "``db.getSisterDB("admin").runCommand();``".
28+
.. code-block:: javascript
29+
30+
db.getSisterDB("admin").runCommand()
2331
2432
MongoDB :term:`drivers <driver>`, and the :option:`mongo` shell may
2533
provide helper interfaces for issuing database commands.
2634

27-
All examples in this reference are provided as documents.
35+
This document primarily provides examples as "prototype" documents,
36+
with references to available shell helpers when possible.
2837

2938
User Commands
3039
-------------
@@ -37,25 +46,27 @@ Sharding
3746

3847
.. dbcommand:: addShard
3948

40-
The ``addShard`` command registers a new with a sharded cluster.
41-
You must run this command against a :option:`mongos` instance. The command
42-
takes the following form: ::
49+
The ``addShard`` command registers a new with a sharded
50+
cluster. You must run this command against a :option:`mongos`
51+
instance. The command takes the following form: ::
4352

4453
{ addshard: "<hostname>:<port>" }
4554

4655
Replace "``<hostname>:<port>``" with the hostname and port of the
4756
database instance you want to add as a shard. Because the
4857
:option:`mongos` instances do not have state and distribute
49-
configuration in the :term:`configdb`s, you send this
58+
configuration in the :term:`configdbs <configdb>`, you send this
5059
command to only one :option:`mongos` instance.
5160

5261
There are two optional parameters:
5362

54-
- **name**. If no name is specified, a name will be automatically
55-
provided to uniquely identify the shard.
56-
- **maxSize** Unless specified, shards will consume the total amount
57-
of available space on their machines if necessary. Use the ``maxSize`` value to
58-
limit the amount of space the database can use.
63+
- **name**. Unless specified, a name will be automatically provided
64+
to uniquely identify the shard.
65+
66+
- **maxSize** Unless specified, shards will consume the total
67+
amount of available space on their machines if necessary. Use the
68+
``maxSize`` value to limit the amount of space the database can
69+
use.
5970

6071
.. note::
6172

@@ -144,7 +155,7 @@ Sharding
144155

145156
Each database in a sharded cluster is assigned a primary shard. If the shard you want to remove
146157
is also the primary of one the cluster's databases, then you must manually move the database to
147-
a new shard. This can be only after the shard has been drained. See the :mongodb:command:`moveprimary` command
158+
a new shard. This can be only after the shard has been drained. See the :dbcommand:`moveprimary` command
148159
for details.
149160

150161
Once all chunks and databases have been removed from the shard, you
@@ -161,9 +172,9 @@ Sharding
161172

162173
When the command returns, the database's primary location will have been
163174
shifted to the designated :term:`shard`. To fully decomission a
164-
shard, use the :mongodb:dbcommand:`removeshard` command.
175+
shard, use the :dbcommand:`removeshard` command.
165176

166-
.. warning:: Do not use :mongodb:dbcommand:`moveprimary` if you have
177+
.. warning:: Do not use :dbcommand:`moveprimary` if you have
167178
sharded collections and the :term:`draining` process has not
168179
completed.
169180

@@ -260,8 +271,9 @@ Aggregation
260271

261272
Only the ``map`` and ``reduce`` options are required, all other
262273
fields are optional. The ``map`` and ``reduce`` functions are
263-
written in JavaScript. See :doc:`/core/map-reduce` for more information
264-
on using the ``mapReduce`` command.
274+
written in JavaScript.
275+
276+
.. seealso:: ":js:func:`mapReduce()`" and ":doc:`/core/map-reduce`"
265277

266278
.. slave-ok
267279
@@ -281,8 +293,8 @@ TODO lacking a lot of documentation. Can you describe each option in the way you
281293

282294
{ findAndModify: collection, <options> }
283295

284-
The shell and many :term:`drivers <driver>` also provide a
285-
``db.findAndModify();`` method.
296+
The shell and many :term:`drivers <driver>` provide a
297+
:js:func:`findAndModify()` helper method.
286298

287299
The following options are available:
288300

@@ -320,7 +332,11 @@ TODO: link to more complete documentation with common examples.
320332

321333
Here, all distinct values of the field (or "``key``") ``age`` are
322334
returned in documents that match the query "``{ field: { $exists:
323-
true }``". **Note that the query is optional**.
335+
true }``".
336+
337+
.. note::
338+
339+
The query portion of the :dbcommand:`distinct` is optional.
324340

325341
The shell and many :term:`drivers <driver>` provide a helper method that provides
326342
this functionality. You may prefer the following equivalent syntax: ::
@@ -340,23 +356,24 @@ are required and which are options? For instance, required options could be in b
340356

341357
{ eval: function() { return 3+3 } }
342358

343-
The shell also provides a helper method, so you can express the above
344-
the above like so: ::
359+
The shell also provides a helper method, so you can express the
360+
above like so: ::
345361

346362
db.eval( function { return 3+3 } } );
347363

348-
Note that functions entered directly into the shell will be evaluated
349-
by the shell's JavaScript interpreter. If you want to use the server's
364+
Note the shell's Java Script interpreter evaluates functions
365+
entered directly into the shell. If you want to use the server's
350366
interpreter, you must run ``eval``.
351367

352368
Note the following behaviors and limitations:
353369

354370
- ``eval`` does not work in :term:`sharded <sharding>`
355371
environments.
356372

357-
- The ``eval`` operation take a write lock by default. This means that writes to
358-
database aren't permitted while it's running. You can, however, disable the lock
359-
by setting the ``nolock`` flag to ``true``. For example: ::
373+
- The ``eval`` operation take a write lock by default. This means
374+
that writes to database aren't permitted while it's running. You
375+
can, however, disable the lock by setting the ``nolock`` flag to
376+
``true``. For example: ::
360377

361378
{ eval: function() { return 3+3 }, nolock: true }
362379

@@ -529,12 +546,12 @@ TODO: see also -- replica set config options.
529546
.. slave-ok, admin-only
530547
531548
Geospatial Commands
532-
~~~~~~~~~~~
549+
~~~~~~~~~~~~~~~~~~~
533550

534551
.. dbcommand:: geoNear
535552

536553
The ``geoNear`` command provides an alternative to the
537-
:mongodb:dbcommand:`$near` operator. In addition to the
554+
:dbcommand:`$near` operator. In addition to the
538555
functionality of ``$near``, ``geoNear`` returns the distance of
539556
each item from the specified point along with additional diagnostic
540557
information. For example: ::
@@ -1136,9 +1153,11 @@ Diagnostics
11361153
.. dbcommand:: validate
11371154

11381155
The ``validate`` command checks the contents of a namespace by
1139-
scanning data structures, and indexes for correctness. The command
1156+
scanning data structures, and indexes for correctness. The command
11401157
can be slow to run particularly on larger data sets. Consider the
1141-
following syntax: ::
1158+
following syntax:
1159+
1160+
.. code-block:: javascript
11421161
11431162
{ validate: "collection" }
11441163
@@ -1151,12 +1170,25 @@ Diagnostics
11511170
- "``scandata: false``" skips the scan of the base collection
11521171
without skipping the scan of the index.
11531172

1154-
The ``mongo`` shell also provides a shell wrapper which is
1155-
equivalent to the first example above: ::
1173+
The :option:`mongo` shell provides the :js:func:`validate()` method
1174+
around the :dbcommand:`validate` command for easy use. The
1175+
following command at the :option:`mongo` shell is equivalent to the
1176+
example above:
1177+
1178+
.. code-block:: javascript
11561179
11571180
db.collection.validate();
11581181
1159-
TODO factcheck; the options on the REST interface and wiki differ
1182+
Use one of the following forms to perform the full collection
1183+
validation:
1184+
1185+
.. code-block:: javascript
1186+
1187+
db.collection.validate(true)
1188+
db.runCommand( { validate: "collection", full: true } )
1189+
1190+
.. warning:: This command is resource intensive and may have an
1191+
impact on the performance of your MongoDB instance.
11601192

11611193
.. dbcommand:: top
11621194

@@ -1172,7 +1204,7 @@ TODO factcheck; the options on the REST interface and wiki differ
11721204
- insert
11731205
- update
11741206
- remove
1175-
- commands.
1207+
- commands
11761208

11771209
The command takes the following form: ::
11781210

@@ -1454,6 +1486,11 @@ Other Commands
14541486

14551487
TODO find md5 "root" argument, and other functionality.
14561488

1489+
:option:`mongos` commands
1490+
-------------------------
1491+
1492+
TODO document mongos commands DOCS-112
1493+
14571494
Internal Use
14581495
------------
14591496

source/reference/operators.rst

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -671,9 +671,8 @@ TODO determine what the performance impacts of using $pushAll with single values
671671
db.collection.update( { field: 1 }, { $bit: { field: { and: 5 } } } );
672672
673673
Here, the ``$bit`` operator updates the integer value of the filed
674-
named ``field`` with a bitwise "``and: 5``" operation.
675-
676-
TODO expand coverage of $bit which I need to understand the use better.
674+
named ``field`` with a bitwise "``and: 5``" operation. This
675+
operator only works with number types.
677676

678677
.. operator:: $atomic
679678

0 commit comments

Comments
 (0)