Skip to content

DOCS-4677 - options format for db.collection.stats() #2113

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
66 changes: 66 additions & 0 deletions source/reference/method/db.collection.stats-options.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
object:
name: db.collection.stats
type: method
field:
optional: true
type: field
name: scale
type: number
position: 1
description: |
Identical to the scalar parameter of the same name.

.. versionadded:: 2.8
---
object:
name: db.collection.stats
type: method
field:
optional: true
type: field
name: indexDetails
type: boolean
position: 2
description: |
Specifies whether to display index details.

Defaults to ``false``.

.. versionadded:: 2.8
---
object:
name: db.collection.stats
type: method
field:
optional: true
type: field
name: indexDetailsField
type: document
position: 3
description: |
Provided that ``indexDetails`` is set to ``true``, allows filtering of
index details by specifying the index ``key``, as returned by
:method:`~db.collection.getIndexes()`. Mutually exclusive with
``indexDetailsName``

.. versionadded:: 2.8

---
object:
name: db.collection.stats
type: method
field:
optional: true
type: field
name: indexDetailsName
type: string
position: 4
description: |
Provided that ``indexDetails`` is set to ``true``, allows filtering of
index details by specifying the index ``name``, as returned by
:method:`~db.collection.getIndexes()`. Mutually exclusive with
``indexDetailsKey``

.. versionadded:: 2.8

...
20 changes: 20 additions & 0 deletions source/reference/method/db.collection.stats-param.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,24 @@ description: |
The scale used in the output to display the sizes of items. By
default, output displays sizes in bytes. To display kilobytes rather
than bytes, specify a ``scale`` value of ``1024``.

.. versionchanged:: 2.8
Legacy parameter format. Mutually exclusive with ``options`` as a
document.
---
object:
name: db.collection.stats
type: method
field:
optional: true
type: param
name: options
type: document
position: 2
description: |
Alternate option format. Mutually exclusive with ``scale`` as a
scalar parameter. The use of this format optionally allows suppression
or filtering of index details.

.. versionadded:: 2.8
...
21 changes: 18 additions & 3 deletions source/reference/method/db.collection.stats.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8,27 +8,42 @@ Definition
----------

.. method:: db.collection.stats(scale)
.. method:: db.collection.stats(options)

Returns statistics about the collection. The method includes
the following parameter:
the following parameters:

.. include:: /reference/method/db.collection.stats-param.rst

The ``options`` document can contain the following fields and values:

.. include:: /reference/method/db.collection.stats-options.rst

:returns: A :term:`document` that contains statistics
on the specified collection.

The :method:`~db.collection.stats()` method provides a wrapper
around the database command
:dbcommand:`collStats`.

Example
-------
Examples
--------

The following operation returns stats on the ``people`` collection:

.. code-block:: javascript

db.people.stats()

The following operation returns stats on the ``orders`` collection,
suppressing all index stats except for those of the ascending index on
the ``order_date`` field, and expressing sizes in kilobytes:

.. code-block:: javascript

db.orders.stats({scale:1024,
indexDetails:true,
indexKey:{order_date:1}})

.. seealso:: :doc:`/reference/command/collStats` for an
overview of the output of this command.