简体   繁体   English

rmongo和查询

[英]rmongo and query-ing

I have difficulty with writing query via rmongo .. 我很难通过rmongo编写查询..

mongo <- mongoDbConnect(dbName="baba", host="inja.com",port='27017')
dbAuthenticate(mongo, 'alaki', 'dolaki')
dbShowCollections(mongo)
> Acol Bcol Ccol Dcol

now : 现在:

result = dbGetQuery(mongo, "settings", "{find_one()}",0,10)
> Error in .jcall(rmongo.object@javaMongo, "S", "dbGetQuery", collection,  : 
      com.mongodb.util.JSONParseException: 
    {find_one()}

I appreciate if someone give me some hint and help me to make a table or R list from my database. 如果有人给我一些提示并帮助我从我的数据库中创建一个表或R列表,我感激不尽。

The query argument for dbGetQuery() should be the data you want to search for, not find_one(). dbGetQuery()的查询参数应该是您要搜索的数据,而不是find_one()。

The result of a dbGetQuery() will be a Data Frame . dbGetQuery()的结果将是一个数据框

Example usage: 用法示例:

# Find documents in "settings" collection (no query criteria); limit results to 10
result=dbGetQuery(mongo, "settings","{}",0,10)

# Find all documents that have a value of "blackbox" for the "widget" column
result=dbGetQuery(mongo, "settings","{'widget':'blackbox'}")

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM