Skip to content

DOCS-5246: adds reference page for setVerboseShell() method #2356

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
6 changes: 5 additions & 1 deletion source/includes/ref-toc-method-native.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,11 @@ name: ":method:`removeFile()`"
file: /reference/method/removeFile
description: "Removes the specified file from the local file system."
---
name: ":method:`setVerboseShell()`"
file: /reference/method/setVerboseShell
description: "Configures the :program:`mongo` shell to report operation timing."
---
name: ":method:`_srand()`"
file: /reference/method/srand
description: "For internal use."
...
...
55 changes: 55 additions & 0 deletions source/reference/method/setVerboseShell.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
=================
setVerboseShell()
=================

.. default-domain:: mongodb

.. method:: setVerboseShell()

The :method:`setVerboseShell()` method configures the :program:`mongo`
shell to print the duration of each operation.

:method:`setVerboseShell()` has the form:

.. code-block:: javascript

setVerboseShell(true)

:method:`setVerboseShell()` takes one boolean parameter. Specify
``true`` or leave the parameter blank to activate the verbose shell.
Specify ``false`` to deactivate.

Example
-------

The following example demonstrates the behavior of the verbose shell:

#. From the :program:`mongo` shell, set verbose shell to ``true``:

.. code-block:: sh

setVerboseShell(true)

#. With verbose shell set to ``true``, run :method:`db.collection.aggregate()`:

.. code-block:: sh

db.restaurants.aggregate(
[
{ $match: { "borough": "Queens", "cuisine": "Brazilian" } },
{ $group: { "_id": "$address.zipcode" , "count": { $sum: 1 } } }
]
);

#. In addition to returning the results of the operation, the
:program:`mongo` shell now displays information about the duration of
the operation:

.. code-block:: sh

{ "_id" : "11377", "count" : 1 }
{ "_id" : "11368", "count" : 1 }
{ "_id" : "11101", "count" : 2 }
{ "_id" : "11106", "count" : 3 }
{ "_id" : "11103", "count" : 1 }
Fetched 5 record(s) in 0ms