I'm using the dbGetQueryForKeys
function (which I learned about here), and don't seem to be getting proper return values---it collects the right keys, but the values are all NA.
Here's my query in the mongo console, which produces what I expect:
db.final.find({},{"ids.myid":1,"org.name":1,"_id":0}).skip(0).limit(5000)
This produces the list of...
{"ids" : {"myid": "123"}, "org": {"name": "Fred"}},
However, the equivalent in RMongo:
dbGetQueryForKeys(db,'final', '{}','{"ids.myid":1,"org.name":1,"_id":0}',skip=0,limit=5000)
Produces
ids.myid org.name X_id
1 NA NA NA
2 NA NA NA
3 NA NA NA
There are a couple problems:
- It has NAs for everything
- The X_id column is still there, even though it was 0'd.
But it does correctly /omit/ all the rest of the keys, so it's clearly recognizing the command at some level, just returning the wrong values for these.
Now, documentation says this:
The output is a data.frame object
and will work properly only if the mongoDB collection contains
primitive data types. It may not work properly if there are any
embedded documents or arrays.
This seems like the likely problem in that I am querying nested variables. However, the return values of those nestings are themselves singular, ids.myid and org.name are both strings and not arrays. Still, is this really the case? RMongo only works for completely flat collections with no nesting whatsoever?