Skip to content

Commit 4666daa

Browse files
schmallisokay-kim
authored andcommitted
DOCS-5246: adds reference page for setVerboseShell() method
Signed-off-by: kay <[email protected]>
1 parent 5923abe commit 4666daa

File tree

2 files changed

+60
-1
lines changed

2 files changed

+60
-1
lines changed

source/includes/ref-toc-method-native.yaml

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,11 @@ name: ":method:`removeFile()`"
7878
file: /reference/method/removeFile
7979
description: "Removes the specified file from the local file system."
8080
---
81+
name: ":method:`setVerboseShell()`"
82+
file: /reference/method/setVerboseShell
83+
description: "Configures the :program:`mongo` shell to report operation timing."
84+
---
8185
name: ":method:`_srand()`"
8286
file: /reference/method/srand
8387
description: "For internal use."
84-
...
88+
...
Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
=================
2+
setVerboseShell()
3+
=================
4+
5+
.. default-domain:: mongodb
6+
7+
.. method:: setVerboseShell()
8+
9+
The :method:`setVerboseShell()` method configures the :program:`mongo`
10+
shell to print the duration of each operation.
11+
12+
:method:`setVerboseShell()` has the form:
13+
14+
.. code-block:: javascript
15+
16+
setVerboseShell(true)
17+
18+
:method:`setVerboseShell()` takes one boolean parameter. Specify
19+
``true`` or leave the parameter blank to activate the verbose shell.
20+
Specify ``false`` to deactivate.
21+
22+
Example
23+
-------
24+
25+
The following example demonstrates the behavior of the verbose shell:
26+
27+
#. From the :program:`mongo` shell, set verbose shell to ``true``:
28+
29+
.. code-block:: sh
30+
31+
setVerboseShell(true)
32+
33+
#. With verbose shell set to ``true``, run :method:`db.collection.aggregate()`:
34+
35+
.. code-block:: sh
36+
37+
db.restaurants.aggregate(
38+
[
39+
{ $match: { "borough": "Queens", "cuisine": "Brazilian" } },
40+
{ $group: { "_id": "$address.zipcode" , "count": { $sum: 1 } } }
41+
]
42+
);
43+
44+
#. In addition to returning the results of the operation, the
45+
:program:`mongo` shell now displays information about the duration of
46+
the operation:
47+
48+
.. code-block:: sh
49+
50+
{ "_id" : "11377", "count" : 1 }
51+
{ "_id" : "11368", "count" : 1 }
52+
{ "_id" : "11101", "count" : 2 }
53+
{ "_id" : "11106", "count" : 3 }
54+
{ "_id" : "11103", "count" : 1 }
55+
Fetched 5 record(s) in 0ms

0 commit comments

Comments
 (0)