Skip to content

Commit 6613261

Browse files
committed
DOCS-504 Port Aggregation wiki page
1 parent 53f1435 commit 6613261

File tree

7 files changed

+57
-57
lines changed

7 files changed

+57
-57
lines changed

source/reference/command/count.txt

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -42,31 +42,31 @@ count
4242

4343
db.runCommand( { count: 'orders' } )
4444

45-
The result displays the count ``n`` of ``26`` and the command
46-
status ``ok`` as ``1``:
45+
In the result, the ``n``, which represents the count, is ``26``
46+
and the command status ``ok`` is ``1``:
4747

4848
.. code-block:: javascript
4949

5050
{ "n" : 26, "ok" : 1 }
5151

5252
- Count the number of the documents in the ``orders`` collection
53-
with the field ``ord_dt`` greater than ``new Date('01\01\2012')``:
53+
with the field ``ord_dt`` greater than ``new Date('01/01/2012')``:
5454

5555
.. code-block:: javascript
5656

5757
db.runCommand( { count:'orders',
5858
query: { ord_dt: { $gt: new Date('01/01/2012') } }
5959
} )
6060

61-
The result displays the count ``n`` of ``13`` and the command
62-
status ``ok`` as ``1``:
61+
In the result, the ``n``, which represents the count, is ``13``
62+
and the command status ``ok`` is ``1``:
6363

6464
.. code-block:: javascript
6565

6666
{ "n" : 13, "ok" : 1 }
6767

6868
- Count the number of the documents in the ``orders`` collection
69-
with the field ``ord_dt`` greater than ``new Date('01\01\2012')``
69+
with the field ``ord_dt`` greater than ``new Date('01/01/2012')``
7070
skipping the first ``10`` matching records:
7171

7272
.. code-block:: javascript
@@ -75,8 +75,8 @@ count
7575
query: { ord_dt: { $gt: new Date('01/01/2012') } },
7676
skip: 10 } )
7777

78-
The result displays the count ``n`` of ``3`` and the command
79-
status ``ok`` as ``1``:
78+
In the result, the ``n``, which represents the count, is ``3`` and
79+
the command status ``ok`` is ``1``:
8080

8181
.. code-block:: javascript
8282

source/reference/command/distinct.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,13 +51,13 @@ distinct
5151

5252
- Return an array of the distinct values of the field ``ord_dt``
5353
from the documents in the ``orders`` collection where the
54-
``ord_dt`` is greater than ``new Date('01\01\2012')``:
54+
``price`` is greater than ``10``:
5555

5656
.. code-block:: javascript
5757

5858
db.runCommand ( { distinct: 'orders',
5959
key: 'ord_dt',
60-
query: { ord_dt: { $gt: new Date('01/01/2012') } }
60+
query: { price: { $gt: 10 } }
6161
} )
6262

6363
.. note::

source/reference/command/group.txt

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -15,23 +15,24 @@ group
1515
The :dbcommand:`group` command takes the following prototype
1616
form:
1717

18-
.. code-block:: javascript
18+
.. code-block:: none
1919

2020
{ group: { ns: <namespace>,
2121
key: <key>,
2222
$reduce: <reduce function>,
2323
$keyf: <key function>,
2424
cond: <query>,
25-
finalize: <finalize fundtion> } }
25+
finalize: <finalize function> } }
2626

2727
The command fields are as follows:
28-
28+
2929
:field ns:
3030

3131
Specifies the collection from which to perform the group by
3232
operation.
3333

34-
:field key: Specifies one or more document fields to group by.
34+
:field key: Specifies one or more document fields to group. Returns
35+
a "key object" for use as the grouping key.
3536

3637
:field $reduce: Specifies an aggregation function that operates on
3738
the documents during the grouping operation, such as
@@ -41,11 +42,11 @@ group
4142

4243
:field initial: Initializes the aggregation result document.
4344

44-
:field $keyf: Optional. Alternative to the ``key`` field. Specifies a
45-
function that creates a "key object" for use as the
46-
grouping key. Use the ``keyf`` instead of ``key`` to
47-
group by calculated fields rather than existing
48-
document fields.
45+
:field $keyf: Optional. Alternative to the ``key`` field. Specifies a
46+
function that creates a "key object" for
47+
use as the grouping key. Use the ``keyf`` instead of
48+
``key`` to group by calculated fields rather than
49+
existing document fields.
4950

5051
:field cond: Optional. Specifies the selection criteria to determine
5152
which documents in the collection to process. If the
@@ -112,7 +113,7 @@ group
112113

113114
- The following example groups by the ``ord_dt`` and ``item.sku``
114115
fields those documents that have ``ord_dt`` greater than
115-
``01-01-2011``:
116+
``01/01/2012``:
116117

117118
.. code-block:: javascript
118119

@@ -164,7 +165,7 @@ group
164165

165166
- The following example groups by the ``ord_dt`` and ``item.sku``
166167
fields, those documents that have ``ord_dt`` greater than
167-
``01-01-2011`` and calculates the sum of the ``qty`` field for each
168+
``01/01/2012`` and calculates the sum of the ``qty`` field for each
168169
grouping:
169170

170171
.. code-block:: javascript
@@ -215,7 +216,7 @@ group
215216

216217

217218
- The following example groups by the calculated ``day_of_week`` field,
218-
those documents that have ``ord_dt`` greater than ``01-01-2011`` and
219+
those documents that have ``ord_dt`` greater than ``01/01/2012`` and
219220
calculates the sum, count, and average of the ``qty`` field for each
220221
grouping:
221222

source/reference/method/cursor.count.txt

Lines changed: 21 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -7,31 +7,34 @@ cursor.count()
77
.. method:: cursor.count()
88

99
The :method:`count() <cursor.count()>` method counts the number of
10-
documents referenced by a cursor.
11-
12-
The :method:`count() <cursor.count()>` can accept the following
13-
argument:
10+
documents referenced by a cursor. Append the :method:`count()
11+
<cursor.count()>` method to a :method:`find()
12+
<db.collection.find()>` query to return the number of matching
13+
documents, as in the following prototype:
14+
15+
.. code-block:: javascript
16+
17+
db.collection.find().count()
18+
19+
This operation does not actually perform the :method:`find()
20+
<db.collection.find()>`; instead, the operation counts the results
21+
that would be returned by the :method:`find()
22+
<db.collection.find()>`.
1423

15-
:param boolean override:
24+
The :method:`count() <cursor.count()>` can accept the following argument:
1625

26+
:param boolean applySkipLimit:
27+
1728
Optional. Specifies whether to consider the effects of the
1829
:method:`cursor.skip()` and :method:`cursor.limit()` methods
1930
in the count. By default, the :method:`count()
2031
<cursor.count()>` method ignores the effects of the
2132
:method:`cursor.skip()` and :method:`cursor.limit()`. Set
22-
``override`` to ``true`` to consider the effect of these
23-
methods.
33+
``applySkipLimit`` to ``true`` to consider the effect of
34+
these methods.
2435

2536
.. seealso:: :method:`cursor.size()`
26-
27-
Append the :method:`count() <cursor.count()>` method to a
28-
:method:`find() <db.collection.find()>` query to return the number
29-
of matching documents, as in the following prototype:
30-
31-
.. code-block:: javascript
32-
33-
db.collections.find().count()
34-
37+
3538
MongoDB also provides the shell wrapper
3639
:method:`db.collection.count()` for the
3740
``db.collection.find().count()`` construct.
@@ -46,25 +49,16 @@ cursor.count()
4649
db.orders.find().count()
4750

4851
- Count the number of the documents in the ``orders`` collection
49-
with the field ``ord_dt`` greater than ``new Date('01\01\2012')``:
52+
with the field ``ord_dt`` greater than ``new Date('01/01/2012')``:
5053

5154
.. code-block:: javascript
5255

5356
db.orders.find( { ord_dt: { $gt: new Date('01/01/2012') } } ).count()
5457

5558
- Count the number of the documents in the ``orders`` collection
56-
with the field ``ord_dt`` greater than ``new Date('01\01\2012')``
57-
*ignoring* the effect of the ``limit(5)``:
58-
59-
.. code-block:: javascript
60-
61-
db.orders.find( { ord_dt: { $gt: new Date('01/01/2012') } } ).limit(5).count()
62-
63-
- Count the number of the documents in the ``orders`` collection
64-
with the field ``ord_dt`` greater than ``new Date('01\01\2012')``
59+
with the field ``ord_dt`` greater than ``new Date('01/01/2012')``
6560
*taking into account* the effect of the ``limit(5)``:
6661

6762
.. code-block:: javascript
6863

6964
db.orders.find( { ord_dt: { $gt: new Date('01/01/2012') } } ).limit(5).count(true)
70-

source/reference/method/db.collection.count.txt

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,15 +7,20 @@ db.collection.count()
77
.. method:: db.collection.count( )
88

99
The :method:`db.collection.count()` method is a shell wrapper that
10-
returns the count of documents from a :method:`find()
10+
returns the count of documents that would match a :method:`find()
1111
<db.collection.find()>` query; i.e., :method:`db.collection.count()`
1212
method is equivalent to:
1313

1414
.. code-block:: javascript
1515

1616
db.collection.find(<query>).count();
17+
18+
This operation does not actually perform the :method:`find()
19+
<db.collection.find()>`; instead, the operation counts the results
20+
that would be returned by the :method:`find()
21+
<db.collection.find()>`.
1722

18-
The :method:`db.collection.count()` method can accepts the following argument:
23+
The :method:`db.collection.count()` method can accept the following argument:
1924

2025
:param document query: Specifies the selection query criteria.
2126

@@ -34,7 +39,7 @@ db.collection.count()
3439
db.orders.find().count()
3540

3641
- Count the number of the documents in the ``orders`` collection
37-
with the field ``ord_dt`` greater than ``new Date('01\01\2012')``:
42+
with the field ``ord_dt`` greater than ``new Date('01/01/2012')``:
3843

3944
.. code-block:: javascript
4045

source/reference/method/db.collection.distinct.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,10 +50,10 @@ db.collection.distinct()
5050

5151
- Return an array of the distinct values of the field ``ord_dt``
5252
from the documents in the ``orders`` collection where the
53-
``ord_dt`` is greater than ``new Date('01\01\2012')``:
53+
``price`` is greater than ``10``:
5454

5555
.. code-block:: javascript
5656

5757
db.orders.distinct( 'ord_dt',
58-
{ ord_dt: { $gt: new Date('01/01/2012') } }
58+
{ price: { $gt: 10 } }
5959
)

source/reference/method/db.collection.group.txt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ following prototype:
9090

9191
- The following example groups by the ``ord_dt`` and ``item.sku``
9292
fields those documents that have ``ord_dt`` greater than
93-
``01-01-2011``:
93+
``01/01/2011``:
9494

9595
.. code-block:: javascript
9696

@@ -128,7 +128,7 @@ following prototype:
128128

129129
- The following example groups by the ``ord_dt`` and ``item.sku``
130130
fields, those documents that have ``ord_dt`` greater than
131-
``01-01-2011`` and calculates the sum of the ``qty`` field for each
131+
``01/01/2011`` and calculates the sum of the ``qty`` field for each
132132
grouping:
133133

134134
.. code-block:: javascript
@@ -170,7 +170,7 @@ following prototype:
170170

171171

172172
- The following example groups by the calculated ``day_of_week`` field,
173-
those documents that have ``ord_dt`` greater than ``01-01-2011`` and
173+
those documents that have ``ord_dt`` greater than ``01/01/2011`` and
174174
calculates the sum, count, and average of the ``qty`` field for each
175175
grouping:
176176

0 commit comments

Comments
 (0)