Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我知道我在某处看到过这个解决方案,但我现在似乎找不到它。我正在尝试在连接到另一个时查询一个 MongoDB 数据库。这应该是可能的,而无需在运行查询之前显式连接到其他数据库。有谁知道这样做的正确语法?
要对同一 MongoDB 服务器上的另一个数据库运行命令,可以在mongoshell 中使用:
mongo
db.getSiblingDB('dbname').collection.command()
例如:
db.getSiblingDB('test').foo.find()