Description Usage Arguments Value Examples
Retrieve all data from a mongodb collection. Optionally, replace the collection data first.
1 | get_mongo_collection(collection, db, connection_string, replace_with = NULL)
|
collection |
Name of the collection. |
db |
Name of the database the collection is in. |
connection_string |
Address of the mongodb server in mongo connection string [URI format](https://docs.mongodb.com/manual/reference/connection-string/). |
replace_with |
Default is NULL. If passed, must be a dataframe, named list (for single record) or character vector with json strings (one string for each row). |
Returns all data in the given collection as a dataframe.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 | ## Not run:
# Get the data in my_collection (in the my_db database)
get_mongo_collection(
"my_collection", "my_db",
connection_string = glue::glue(
"mongodb+srv://{MONGO_USER}:{MONGO_PASS}@{MONGO_HOST}",
"/?tls=true&retryWrites=true&w=majority"
)
)
# Replace the data in my_collection (in the my_db database) with the data in
# my dataframe, then get that data
get_mongo_collection(
"my_collection", "my_db",
connection_string = glue::glue(
"mongodb+srv://{MONGO_USER}:{MONGO_PASS}@{MONGO_HOST}",
"/?tls=true&retryWrites=true&w=majority"
),
replace_with = my_dataframe
)
## End(Not run)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.