2017-02-27 53 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()