jeroen / mongolite

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

Get database name of a connection to a new collection #140

Closed Serenthia closed 6 years ago

Serenthia commented 6 years ago

If I connect to a collection with documents, I can query it to get the following attributes:

host <- env$info()$server$host
database <- stringr::str_match(env$info()$stats$ns, "(.*)\\.")[,2]
collection <- env$info()$name

If I create a new collection, env$stats is NULL before any documents are added, and so there is no way to obtain the name of the database.

Could this be under $info() at the same level as $name?