jeroen / mongolite

Fast and Simple MongoDB Client for R
https://jeroen.github.io/mongolite/
286 stars 65 forks source link

listCollections Question #154

Closed jocca-mac closed 5 years ago

jocca-mac commented 5 years ago

When I use root$run('{"listCollections":1}') I successfully get back a list of lists that contain (among other things) the collection names in the database. However, I then try to extract the collection names using something like: root$cursor$firstBatch$name. Sometimes that works, and sometimes it doesn't. I think the "structure" of that list of list that is returned from root$run('{"listCollections":1}') changes from day to day. What is the best way to reliably extract a vector of the just the actual collection names from that list of lists? Thanks.

jeroen commented 5 years ago

Try using root$run('{"listCollections":1}', simplify = FALSE). This will return the data in consistent manner.

jocca-mac commented 5 years ago

Thank you. But I'm having a problem.. This works:

root$run('{"listCollections":1}')

But when I try adding the simplify I get this error:

root$run('{"listCollections":1}', simplify=FALSE) Error in root$run("{\"listCollections\":1}", simplify = FALSE) : unused argument (simplify = FALSE) What am I doing wrong? Thanks!

jeroen commented 5 years ago

Are you sure you have the latest version of mongolite? Try install.packages("mongolite")

jocca-mac commented 5 years ago

That worked. Thank you!