[英]When using rmongodb, unable to see collections in mongoDB
I am having the same issue as in this thread: Unable to see collections in mongo DB when connected through R我遇到了与此线程相同的问题: 通过 R 连接时无法在 mongo DB 中看到集合
I am successfully connected to mongoDB.我已成功连接到 mongoDB。
> mongo.is.connected(mongo)
[1] TRUE
If I run the following code, I see the correct db.如果我运行以下代码,我会看到正确的 db.
> mongo.get.databases(mongo)
[1] "FF"
>
But, when I try to view the collections, it returns character(0)但是,当我尝试查看集合时,它返回 character(0)
> mongo.get.database.collections(mongo , db = "FF")
character(0)
>
If I connect from the shell I can see all the collections, so I know they exist.如果我从 shell 连接,我可以看到所有集合,所以我知道它们存在。
> use FF
switched to db FF
> show collections
kelp_classifications
kelp_groups
kelp_subjects
kelp_users
rmongodb
is no longer supported and removed from CRAN rmongodb
不再受支持并从 CRAN 中删除
Reference: https://github.com/dselivanov/rmongodb参考: https : //github.com/dselivanov/rmongodb
This function is working correctly for me in v1.8.0
:此功能在v1.8.0
对我来说正常工作:
mongo <- mongo.create()
mongo.is.connected(mongo)
# [1] TRUE
db <- "test"
mongo.get.database.collections(mongo, db = db)
[1] "test.test"
The following code seems to work in situations where mongo.get.database.collections(mongo, db = db) results in character(0)以下代码似乎适用于 mongo.get.database.collections(mongo, db = db) 结果为 character(0)
mongo = mongo.create(host = "127.0.0.1:9997", db = "restaurant")
# Create a mongo.bson object with header as "listCollections", which is
# a mongo DB command
command = list(listCollections = "")
command = mongo.bson.from.list(command)
command
>listCollections : 2
# calling mongo DB server to return collections as mongo.bson object
collections = mongo.command(mongo, "restaurant", command)
# convert mongo.bson object to a list
collections = mongo.bson.to.list(collections)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.