此版本的文档已存档,不再提供支持。要升级5.0部署,请参阅 MongoDB 6.0升级程序。
注意
此处列出的原生方法适用于旧版 mongo
shell 。
要使用mongosh
中的原生方法,请参阅 mongosh
中的原生方法。
setVerboseShell()
setVerboseShell()
方法将mongosh
配置为输出每个操作的持续时间。setVerboseShell()
采用以下形式:setVerboseShell(true) setVerboseShell()
接受一个布尔参数。 指定true
或将该参数留空以激活详细shell 。 指定false
以停用。
例子
以下示例演示了 verbose shell的行为:
从
mongosh
中,设立详细shell设置为true
:setVerboseShell(true) 将 verbose shell设立为
true
时,运行db.collection.aggregate()
:db.restaurants.aggregate( [ { $match: { "borough": "Queens", "cuisine": "Brazilian" } }, { $group: { "_id": "$address.zipcode" , "count": { $sum: 1 } } } ] ); 除了返回操作结果外,
mongosh
现在还显示有关操作持续时间的信息:{ "_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