When using rmongodb, unable to see collections in mongoDB

后端 未结 2 670
夕颜
夕颜 2020-12-11 13:09

I am having the same issue as in this thread:Unable to see collections in mongo DB when connected through R

I am successfully connected to mongoDB.

&         


        
2条回答
  •  执笔经年
    2020-12-11 13:52

    The following code seems to work in situations where mongo.get.database.collections(mongo, db = db) results in 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)
    

提交回复
热议问题