2017-02-27 52 views
0

我正在尝试在mongoDB shell中返回一个收集数据。 这些都是我在MongoDB的壳输入的命令:无法在mongoDB shell中返回收集数据

> **show dbs** 
local  0.000GB 
messages 0.000GB 
restapi 0.000GB 
> **use restapi** 
switched to db restapi 
> **show collections** 
messages 
> **restapi.messages.find()** 

错误:

2017-02-26T19:03:50.024+0200 E QUERY [thread1] ReferenceError: restapi is not defined :`

为了证明我有在信息收集的记录,我附上截图:

RoboMongo screenshot

为什么我无法查看收藏内容?

+1

尝试'db.messages.find()'是mongo shell语法,类似于您对于robomongo。更多https://docs.mongodb.com/manual/reference/method/db.collection.find/ – Veeram

+0

谢谢!我虽然'数据库'意味着数据库名称! – osherdo

回答

1

db是关键字,而不是db名称。 尝试db.messages.find() 如果您想要正确的JSON,请尝试db.messages.find()。pretty()