rmongodb: using $or in query

后端 未结 4 1604
离开以前
离开以前 2020-12-21 17:40

I\'m struggling to create a query using $or within R and rmongodb. What I\'d like to emulate is this from cmdline mongo:

db.people.find( { $or : [ {\"person         


        
4条回答
  •  攒了一身酷
    2020-12-21 17:51

    I found this query easier to wrangle in RMongo:

    mongo <- mongoDbConnect(dbName="work", host="localhost",port='27017')
    result <- dbGetQuery(mongo, "people","
        { '$or': [
            {'person.cell':{'$exists':true}},
            {'person.home':{'$exists':true}}
        ]}"
    )
    

    Result will be a data.frame.

提交回复
热议问题