2

我正在使用 MongoDB shell 版本运行 Debian:2.4.3

我跑

use dbname
db.stats.find()

它输出以下内容

> db.stats.find()
Mon May 13 17:55:20.933 JavaScript execution failed: TypeError: Object function (scale){
return this.runCommand( { dbstats : 1 , scale : scale } );
} has no method 'find'

但是在其他集合上运行它可以正常工作。

这个 mongo 实例正在与 nodejs 一起使用。

4

2 回答 2

8

如果您真的在数据库 dbname 中创建了一个名为 stats 的集合,那么我建议您重命名它。在 shell 中,db 对象有一个 stats() 方法来查看数据库的统计信息。

同时,您可以使用稍微复杂的语法:

> db.getSiblingDB("dbname").getCollection("stats").find()
Fetched 0 record(s) in 4ms

或者,如果您在 dbname 中,则:

> db.getCollection("stats").find()
于 2013-05-13T17:19:43.043 回答
0

我想你想要db.stats()

于 2013-05-13T16:21:53.757 回答