【问题标题】:Cannot return a collection data in mongoDB shell无法在 mongoDB shell 中返回集合数据
【发布时间】:2017-02-27 00:36:12
【问题描述】:

我正在尝试在 mongoDB shell 中返回集合数据。 这些是我在 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 未定义:`

为了表明我在消息集合中确实有记录,我附上截图:

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

【问题讨论】:

标签: mongodb


【解决方案1】:

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

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2017-12-22
    • 2018-04-13
    • 1970-01-01
    • 2017-05-15
    • 2015-07-20
    • 1970-01-01
    • 2013-06-05
    相关资源
    最近更新 更多