首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >Rmongo查询函数产生错误

Rmongo查询函数产生错误
EN

Stack Overflow用户
提问于 2018-06-10 20:35:09
回答 1查看 148关注 0票数 0

我试图使用Rmongo library.But查询函数连接R中的mongodb,这给我带来了错误。

代码语言:javascript
复制
> chn = mongoDbConnect("marketing_db", host = 'localhost', port = 27017)
> print(dbShowCollections(chn))
character(0)
> results = dbGetQuery(chn, marketing_data, {}, 0, 5)
Error in dbGetQuery(chn, marketing_data, { : 
  object 'marketing_data' not found
> results = dbGetQuery(chn, "marketing_data", {}, 0, 5)
Error in (function (classes, fdef, mtable)  : 
  unable to find an inherited method for function ‘dbGetQuery’ for signature ‘"RMongo", "character", "NULL", "numeric", "numeric"’
> results = dbGetQuery(chn, "marketing_data", query = {}, skip = 0, limit = 5)
Error in (function (classes, fdef, mtable)  : 
  unable to find an inherited method for function ‘dbGetQuery’ for signature ‘"RMongo", "character", "NULL", "numeric", "numeric"’

其中marketing_db是db,marketing_data是mongodb中的集合。

以下是来自mongo控制台的输出:

代码语言:javascript
复制
> show dbs
admin         0.000GB
config        0.000GB
local         0.000GB
marketing_db  0.001GB
myblogs       0.000GB
test          0.003GB
> use marketing_db
switched to db marketing_db
> show collections
marketing_data
> db.marketing_data.count()
7414
> db.marketing_data.find().pretty().limit(1)
{
        "_id" : ObjectId("5b1d65c6cc6e576297462cdc"),
        "custAge" : 55,
        "profession" : "admin.",
        "marital" : "single"
}

我使用R for windows 3.4.3和MongoDB 3.6.5

请帮助解决此错误。

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2018-06-10 21:32:39

尝试将查询json作为字符串传递:

代码语言:javascript
复制
results = dbGetQuery(chn, "marketing_data", "{}", 0, 5)
票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/50787813

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档