Mongo客户端无法访问以下划线前缀的集合

2024-02-20

我在 Mongo 中用下划线命名了一个集合,并且无法从 shell 访问它:

meteor:PRIMARY> show collections
_assignments
chatmessages
(... other stuff)

尝试在第一个集合上运行任何函数都会导致错误:

meteor:PRIMARY> db._assignments.find()
Thu Jun 19 10:53:28.450 TypeError: Cannot call method 'find' of undefined

然而,其他集合工作正常:

meteor:PRIMARY> db.chatmessages.find()
{ "room" : "j5oau9DJ6GNpT9nR8", "userId" : "at9Kt8NNL4aeof6LE", "text" : "@nomad943 can you take a look at event #1?", "timestamp" : 1391806611977, "_id" : "26GbXa6c4B65FYRxC" }
{ "room" : "T7JfjBhri48bNHAfQ", "userId" : "B82LxmPBZWDnN4N2p", "text" : "Thinking #60 should be deleted, it's a duplicate of #36 and the region is wrong for the province", "timestamp" : ISODate("2014-06-18T18:57:56.480Z"), "_id" : "29pKqPhi4hgxCb2Ky" }

这里发生了什么?


除了 shell 无法使用其默认帮助程序语法解决此问题之外,我没有看到任何问题。您仍然可以在 shell 中访问这样命名的集合:

db.createCollection("_assignments")
{ "ok" : 1 }
db.getCollection("_assignments").find()
db.getCollection("_assignments").insert({ "a": 1 })
WriteResult({ "nInserted" : 1 })
db.getCollection("_assignments").find({ "a": 1 })
{ "_id" : ObjectId("53a36a4047234c4e9bb4feac"), "a" : 1 }
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

Mongo客户端无法访问以下划线前缀的集合 的相关文章

随机推荐