数据库名称中的MongoDB转义特殊字符

数据库名称中的MongoDB转义特殊字符,mongodb,Mongodb,有人知道我如何使用mongodb控制台中的“abc-123”这样的数据库名称在一个命令中执行类似操作吗 use abc-123; db.Configuration.find() 我试过这样的方法 ['abc-123'].Configuration.find() 但什么都没用 谢谢你的帮助 您可以使用db.getSibling()来执行此操作- > db.getSiblingDB("abc-123").Configuration.find() { "_id" : ObjectId

有人知道我如何使用mongodb控制台中的“abc-123”这样的数据库名称在一个命令中执行类似操作吗

 use abc-123;
 db.Configuration.find()
我试过这样的方法

 ['abc-123'].Configuration.find()
但什么都没用

谢谢你的帮助

您可以使用db.getSibling()来执行此操作-

> db.getSiblingDB("abc-123").Configuration.find()

{ "_id" : ObjectId("4fd20ac548b3c185dd9f8e5c"), "name" : "mongo" }
{ "_id" : ObjectId("4fd20ac748b3c185dd9f8e5d"), "x" : 3 }
{ "_id" : ObjectId("4fd20b9648b3c185dd9f8e5e"), "x" : 4, "j" : 1 }
{ "_id" : ObjectId("4fd20b9648b3c185dd9f8e5f"), "x" : 4, "j" : 2 }
{ "_id" : ObjectId("4fd20b9648b3c185dd9f8e60"), "x" : 4, "j" : 3 }
{ "_id" : ObjectId("4fd20b9648b3c185dd9f8e61"), "x" : 4, "j" : 4 }
{ "_id" : ObjectId("4fd20b9648b3c185dd9f8e62"), "x" : 4, "j" : 5 }
{ "_id" : ObjectId("4fd20b9648b3c185dd9f8e63"), "x" : 4, "j" : 6 }
{ "_id" : ObjectId("4fd20b9648b3c185dd9f8e64"), "x" : 4, "j" : 7 }
{ "_id" : ObjectId("4fd20b9648b3c185dd9f8e65"), "x" : 4, "j" : 8 }
{ "_id" : ObjectId("4fd20b9648b3c185dd9f8e66"), "x" : 4, "j" : 9 }
{ "_id" : ObjectId("4fd20b9648b3c185dd9f8e67"), "x" : 4, "j" : 10 }
......
......
这里有一个指向MongoDB的命令引用列表的链接,其中更详细地介绍了getSibling


此外,建议保留数据库名称的字母数字。

Hi…您能接受答案吗?谢谢