通过R连接时无法在mongo DB中看到集合 [英] Unable to see collections in mongo DB when connected through R

查看:103
本文介绍了通过R连接时无法在mongo DB中看到集合的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用"rmongodb"包通过R连接到mongo DB. 连接成功.

I used "rmongodb" package to connect to mongo DB through R. The connection is successful.

> mongo.is.connected(mongo)
[1] TRUE
> 

如果我检查运行mongoDB的主机.

If I check at the host where mongoDB is running.

> use reporting
switched to db reporting

> show collections
MongoIndexing
details
test
>

但是从R

> mongo.get.database.collections(mongo , db="reporting")
character(0)
>

推荐答案

如果提供的数据库中包含集合,则下面的代码将返回一个集合名称数组.否则,它将返回character(0)

The below code will return an array of collection names iff the provided database has collections in it. Otherwise, it will return character(0)

尝试一下:

mongo <- mongo.create(host="127.0.0.1:27017" , db="sample")
mongo.get.database.collections(mongo , "sample")

输出:两个集合分别命名为角色和类别

Output: two collections named roles and categories

"sample.roles"          
"sample.categories" 

要获取所有数据库:

mongo <- mongo.create(host="127.0.0.1:27017")
mongo.get.databases(mongo)

要获取特定数据库中的所有集合,请说出示例:

To get all collections in a specific database say sample:

mongo.get.database.collections(mongo, "sample")

您可以检查 rmongod 链接以获取更多信息.

You can check rmongod link for more info.

这篇关于通过R连接时无法在mongo DB中看到集合的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆