Docs 菜单
Docs 主页
/
MongoDB Manual
/ / /

setVerboseShell()

在此页面上

  • 例子

注意

此处列出的原生方法适用于旧版 mongo Shell。

要使用 mongosh中的原生方法,请参阅mongosh中的原生方法。

setVerboseShell()

The setVerboseShell() method configures mongosh to print the duration of each operation.

setVerboseShell() has the form:

setVerboseShell(true)

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

The following example demonstrates the behavior of the verbose shell:

  1. From mongosh, set verbose shell to true:

    setVerboseShell(true)
  2. With verbose shell set to true, run db.collection.aggregate():

    db.restaurants.aggregate(
    [
    { $match: { "borough": "Queens", "cuisine": "Brazilian" } },
    { $group: { "_id": "$address.zipcode" , "count": { $sum: 1 } } }
    ]
    );
  3. In addition to returning the results of the operation, mongosh now displays information about the duration of the operation:

    { "_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

后退

sleep()

来年

version()

在此页面上