Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/sockets/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Mongodb 使用Mongo CLI查看名为“stats”的集合_Mongodb_Command Line Interface - Fatal编程技术网

Mongodb 使用Mongo CLI查看名为“stats”的集合

Mongodb 使用Mongo CLI查看名为“stats”的集合,mongodb,command-line-interface,Mongodb,Command Line Interface,我没有认真思考,而是创建了一个名为stats的集合,使用MongoDB驱动程序在应用程序中收集聚合数据。它似乎保存正确,并且驱动程序从该集合中正确获取数据,没有任何问题 现在,我没有想到的是,db有一个名为stats的方法,它可以提供有关db实例运行情况的统计信息。这实际上使得无法通过CLI查看stats集合中的记录 显示集合的编辑输出: 此时是否有一种通过CLI与统计数据集合交互的方法?您可以使用db.getCollection方法-明确针对这种情况创建: db.getCollection("

我没有认真思考,而是创建了一个名为stats的集合,使用MongoDB驱动程序在应用程序中收集聚合数据。它似乎保存正确,并且驱动程序从该集合中正确获取数据,没有任何问题

现在,我没有想到的是,db有一个名为stats的方法,它可以提供有关db实例运行情况的统计信息。这实际上使得无法通过CLI查看stats集合中的记录

显示集合的编辑输出:


此时是否有一种通过CLI与统计数据集合交互的方法?

您可以使用db.getCollection方法-明确针对这种情况创建:

db.getCollection("stats").findOne()

哈哈,成功了!谢谢D
<SNIP>:PRIMARY> db.stats.findOne({})
2015-09-24T14:28:25.797-0500 E QUERY    TypeError: Object function (scale){
    return this.runCommand( { dbstats : 1 , scale : scale } );
} has no method 'findOne'
    at (shell):1:10
db.getCollection("stats").findOne()