|
| 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