Getting the URI and DB name from a mongo object
grimmjulian opened this issue · comments
grimmjulian commented
Hello,
I was wondering, if there is a good way to get the URI and the DB name from a mongo object?
For the DB name, I tried m$info()$db
, which returns only NULL
. I then used strsplit(x$info()$stats$ns, "\\.")[[1]][[1]]
, but I feel there should be a better solution?
For URI, I did not find anything.
Thanks in advance!
grimmjulian commented
I found the following solution for my problem:
m <- mongolite::mongo()
get_orig_content <- function(name) {
function(m) {
parent.env(m)[["orig"]][[name]]
}
}
name <- get_orig_content("name") # this is the collection
db <- get_orig_content("db")
url <- get_orig_content("url")
name(m)
db(m)
url(m)