0

I've been trying to figure out how to create a list in R with all of the keys in a collection using Mongolite, but I can't seem to find any examples online. I've been looking at the following Thread (Get names of all keys in the collection) but all of the answers seem to be concerning Python or command line scripting.

If I use the iterate function, db$iterate()$one(), on my database, I am able to return a single entry from the collection that has all of the keys, but it also includes all of the associated values from the database.

If I had to guess, the way to do it would be using the run() command, but I'm not sure where to start.

Thoughts?

FiveCents
  • 25
  • 3

1 Answers1

0

I think I might have found an answer to my own question. I think that one way to do it (albeit slightly janky) would be to return a find() query of the whole collection, but limit the number of rows return to 5-10, similar to the head() funciton in R, and load that into a temporary data.frame. Then once that is loaded, it is relatively easy to strip out the column headings using R's built in functions and save that as its own list for later use.

FiveCents
  • 25
  • 3