Skip to content

Commit

Permalink
Updates
Browse files Browse the repository at this point in the history
  • Loading branch information
jeroen committed Dec 2, 2024
1 parent 628ad22 commit 252cc63
Show file tree
Hide file tree
Showing 5 changed files with 29 additions and 27 deletions.
6 changes: 3 additions & 3 deletions R/mongo.R
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
#' @aliases mongolite
#' @references [Mongolite User Manual](https://jeroen.github.io/mongolite/)
#' @param url address of the mongodb server in mongo connection string
#' [URI format](https://docs.mongodb.com/manual/reference/connection-string)
#' [URI format](https://www.mongodb.com/docs/manual/reference/connection-string)
#' @param db name of database
#' @param collection name of collection
#' @param verbose emit some more output
Expand Down Expand Up @@ -94,9 +94,9 @@
#' \item{\code{disconnect(gc = TRUE)}}{Disconnect collection. The \emph{connection} gets disconnected once the client is not used by collections in the pool.}
#' \item{\code{distinct(key, query = '{}')}}{List unique values of a field given a particular query.}
#' \item{\code{drop()}}{Delete entire collection with all data and metadata.}
#' \item{\code{export(con = stdout(), bson = FALSE, query = '{}', fields = '{}', sort = '{"_id":1}')}}{Streams all data from collection to a \code{\link{connection}} in \href{https://ndjson.org}{jsonlines} format (similar to \href{https://docs.mongodb.com/database-tools/mongoexport/}{mongoexport}). Alternatively when \code{bson = TRUE} it outputs the binary \href{https://bsonspec.org/faq.html}{bson} format (similar to \href{https://docs.mongodb.com/database-tools/mongodump/}{mongodump}).}
#' \item{\code{export(con = stdout(), bson = FALSE, query = '{}', fields = '{}', sort = '{"_id":1}')}}{Streams all data from collection to a \code{\link{connection}} in \href{https://ndjson.org}{jsonlines} format (similar to \href{https://www.mongodb.com/docs/database-tools/mongoexport/}{mongoexport}). Alternatively when \code{bson = TRUE} it outputs the binary \href{https://bsonspec.org/faq.html}{bson} format (similar to \href{https://www.mongodb.com/docs/database-tools/mongodump/}{mongodump}).}
#' \item{\code{find(query = '{}', fields = '{"_id" : 0}', sort = '{}', skip = 0, limit = 0, handler = NULL, pagesize = 1000)}}{Retrieve \code{fields} from records matching \code{query}. Default \code{handler} will return all data as a single dataframe.}
#' \item{\code{import(con, bson = FALSE)}}{Stream import data in \href{https://ndjson.org}{jsonlines} format from a \code{\link{connection}}, similar to the \href{https://docs.mongodb.com/database-tools/mongoimport/}{mongoimport} utility. Alternatively when \code{bson = TRUE} it assumes the binary \href{https://bsonspec.org/faq.html}{bson} format (similar to \href{https://docs.mongodb.com/database-tools/mongorestore/}{mongorestore}).}
#' \item{\code{import(con, bson = FALSE)}}{Stream import data in \href{https://ndjson.org}{jsonlines} format from a \code{\link{connection}}, similar to the \href{https://www.mongodb.com/docs/database-tools/mongoimport/}{mongoimport} utility. Alternatively when \code{bson = TRUE} it assumes the binary \href{https://bsonspec.org/faq.html}{bson} format (similar to \href{https://www.mongodb.com/docs/database-tools/mongorestore/}{mongorestore}).}
#' \item{\code{index(add = NULL, remove = NULL)}}{List, add, or remove indexes from the collection. The \code{add} and \code{remove} arguments can either be a field name or json object. Returns a dataframe with current indexes.}
#' \item{\code{info()}}{Returns collection statistics and server info (if available).}
#' \item{\code{insert(data, pagesize = 1000, stop_on_error = TRUE, ...)}}{Insert rows into the collection. Argument 'data' must be a data-frame, named list (for single record) or character vector with json strings (one string for each row). For lists and data frames, arguments in \code{...} get passed to \code{\link[jsonlite:toJSON]{jsonlite::toJSON}}}
Expand Down
21 changes: 11 additions & 10 deletions R/reader.R
Original file line number Diff line number Diff line change
@@ -1,16 +1,17 @@
#' Standalone BSON reader
#'
#' Utility to read BSON data into R without MongoDB. Useful to read a dump from
#' from a `mongoexport` dump if it fits in memory. This utility does not attempt
#' to convert result into one giant data.frame: the output is a vector of length
#' equal to total number of documents in the bson collection. However it is
#' possible to simplify the separate data objects using [jsonlite][fromJSON] rules,
#' to recognize atomic vectors and data frames in nested bson documents.
#' Reads BSON data from a `mongoexport` dump file directly into R (if it can fit
#' in memory). This utility does not attempt to convert result into one big single
#' data.frame: the output is always a vector of length equal to total number of
#' documents in the collection.
#'
#' An alternative to this function is to import your bson dump into a local mongodb
#' server using the [mongo$import][mongo] function. This requires little memory
#' and once data is in mongodb you can easily query and manipulate it using this
#' package.
#' It is enabled by default to simplify the individual data documents using the
#' same rules as [jsonlite][fromJSON]. This converts nested lists into atomic
#' vectors and data frames when possible, which makes data easier to work with in R.
#'
#' An alternative to this function is to import your BSON file into a local mongodb
#' server using the [mongo$import()][mongo] function. This requires little memory
#' and once data is in mongodb you can easily query and modify it.
#'
#' @export
#' @useDynLib mongolite R_bson_reader_file
Expand Down
2 changes: 1 addition & 1 deletion man/gridfs.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions man/mongo.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

21 changes: 11 additions & 10 deletions man/read_bson.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 252cc63

Please sign in to comment.