【问题标题】:Mongo shell not showing contentMongo shell 不显示内容
【发布时间】:2014-02-23 15:09:19
【问题描述】:

我用 nodejs 和 express 创建了一个 web 应用程序。我正在使用蒙古语连接 mongo db。

虽然我在我的 GET 请求中获得了正确的数据,但当我尝试在 shell 中查看数据时,我看不到任何数据。

这是日志:

mongodb-win32-x86_64-2008plus-2.4.9\bin>mongod.exe --dbpath data\db
Sun Feb 23 20:24:03.176 [initandlisten] MongoDB starting : pid=8736 port=27017 d
bpath=data\db 64-bit host=asnegi-w7
Sun Feb 23 20:24:03.179 [initandlisten] db version v2.4.9
Sun Feb 23 20:24:03.180 [initandlisten] git version: 52fe0d21959e32a5bdbecdc6205
7db386e4e029c
Sun Feb 23 20:24:03.181 [initandlisten] build info: windows sys.getwindowsversio
n(major=6, minor=1, build=7601, platform=2, service_pack='Service Pack 1') BOOST
_LIB_VERSION=1_49
Sun Feb 23 20:24:03.182 [initandlisten] allocator: system
Sun Feb 23 20:24:03.182 [initandlisten] options: { dbpath: "data\db" }
Sun Feb 23 20:24:03.196 [initandlisten] journal dir=data\db\journal
Sun Feb 23 20:24:03.196 [initandlisten] recover : no journal files present, no r
ecovery needed
Sun Feb 23 20:24:03.337 [websvr] admin web console waiting for connections on po
rt 28017
Sun Feb 23 20:24:03.337 [initandlisten] waiting for connections on port 27017
Sun Feb 23 20:24:29.664 [initandlisten] connection accepted from 127.0.0.1:56639
 #1 (1 connection now open)
Sun Feb 23 20:27:20.849 [conn1] end connection 127.0.0.1:56639 (0 connections no
w open)
Sun Feb 23 20:28:08.538 [initandlisten] connection accepted from 127.0.0.1:56687
 #2 (1 connection now open)
Sun Feb 23 20:28:58.317 [conn2] end connection 127.0.0.1:56687 (0 connections no
w open)
Sun Feb 23 20:29:03.051 [initandlisten] connection accepted from 127.0.0.1:56702
 #3 (1 connection now open)
Sun Feb 23 20:29:40.585 [conn3] end connection 127.0.0.1:56702 (0 connections no
w open)
Sun Feb 23 20:29:43.971 [initandlisten] connection accepted from 127.0.0.1:56707
 #4 (1 connection now open)
Sun Feb 23 20:30:18.166 [conn4] end connection 127.0.0.1:56707 (0 connections no
w open)
Sun Feb 23 20:30:22.999 [initandlisten] connection accepted from 127.0.0.1:56712
 #5 (1 connection now open)

对于外壳:

mongodb-win32-x86_64-2008plus-2.4.9\bin>mongo.e
xe
MongoDB shell version: 2.4.9
connecting to: test
> show dbs
bluff_message_db        0.203125GB
local   0.078125GB
message_db      0.203125GB
session_db      0.203125GB
> use session_db;
switched to db session_db
> show collections;
system.indexes
> show collection
Sun Feb 23 20:25:00.362 don't know how to show [collection] at src/mongo/shell/u
tils.js:847
> show collections
system.indexes
> db.sessions
session_db.sessions
> db.sessions.find()
> show dbs
bluff_message_db        0.203125GB
local   0.078125GB
message_db      0.203125GB
session_db      0.203125GB
> use message_db
switched to db message_db
> show collections
messsages
system.indexes
> use messages
switched to db messages
> db.messages
messages.messages
> db.messages.find()
>

它没有显示输出。

我在 shell 中注意到connecting to: test。我在mongo.exe prod 等命令行中给出了dev、prod 等参数,但没有任何效果。它们都显示了数据库和消息,但不显示内容。

我做错了什么?

【问题讨论】:

    标签: node.js mongodb shell express


    【解决方案1】:

    您的收藏名称有拼写错误。您有带有三个“s”字符messsages

    我假设这只是 shell 中的一个“错字”。肌肉记忆使您输入“消息”的“正确”拼写,即使实际集合名称中有错误。

    Mongo 将允许您切换到/使用数据库、集合,即使它们尚不存在。您尝试插入文档的那一刻 - 结构已创建。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2021-08-21
      • 1970-01-01
      • 2014-10-08
      • 2018-12-28
      • 1970-01-01
      • 1970-01-01
      • 2014-02-14
      • 2012-09-24
      相关资源
      最近更新 更多