@@ -325,20 +325,25 @@ Aggregation
325
325
326
326
.. dbcommand:: count
327
327
328
- The :dbcommand:`count` command counts the number of documents in a collection. For example:
328
+ The :dbcommand:`count` command counts the number of documents in a
329
+ collection. For example:
329
330
330
331
.. code-block:: javascript
331
332
332
- db.collection.count():
333
+ > db.runCommand( { count: "collection" } );
334
+ { "n" : 10 , "ok" : 1 }
333
335
334
- In the :program:`mongo` shell, this returns the number of documents in the
335
- collection (e.g. ``collection``). You may also run this command
336
- using the :func:`db.runCommand()` functionality, with the following results:
336
+ In the :program:`mongo` shell, this returns the number of documents
337
+ in the collection (e.g. ``collection``.) You may also use the
338
+ :func:`count() <cursor.count()>` method on any cursor object to
339
+ return a count of the number of documents in that cursor. The
340
+ following operation produces the same result in the
341
+ :program:`mongo` shell:
337
342
338
343
.. code-block:: javascript
339
344
340
- > db.runCommand( { count: " collection" } );
341
- { "n" : 10 , "ok" : 1 }
345
+ > db.collection.count():
346
+ { "n" : 10 , "ok" : 1 }
342
347
343
348
The collection in this example has 10 documents.
344
349
0 commit comments