monPlus: MongoDB client with extra functionality

Description Usage Arguments Value Methods References See Also


Comparable to mongolite::mongo, but with a few extra methods (taggedfind, adjust), an extra RMongo-object, and handles to the collection object and client object exposed, so you can write your own extensions


monPlus(collection, db, url, host, port, verbose = FALSE,
  options = mongolite::ssl_options(), extraSlots = list())



name of collection


name of database


address of the mongodb server in mongo connection string URI format

host, port

alternatively, you can provide a host and port, which is then resolved to "mongodb://host[:port] Ignored if url is given. Defaults to localhost:27017


emit some more output


additional connection options such as SSL keys/certs. See mongolite documentation


list of extra slots/methods to attach to the object. Useful to keep track of additional properties, see for example how it is used with OpenDockerMongo, and to add even more methods. If a function is supplied, it's environment is changed to inside this object.


A pointer to a collection on the server. It can be interfaced using methods, or the client or col attributes.


The same methods as mongo provides, along with the following:

taggedfind(qry='{}', tagfields='_id', arrayfield, sort='{}', skip=0, limit=0, handler=NULL, pagesize=1000, cachesize=5e4, verbose=verbose, stringsAsFactors=default.stringsAsFactors())

Find values inside documents, with pointers to the root-document, see taggedMongofind. Verbose defaults to the value given at creation of monPlus, but can be adjusted.

adjust(findqry='{}', infields=c('All'), setfield='extraInfo',unboxsubf=c(), FUN, FUNvectorized=FALSE, skip=0, limit=0,pagesize=1000, verbose=verbose)

Adjust values in DB with FUN, see mongoAdjust


Test if connection is still alive, and documents can be inserted, retrieved and removed. For debugging, you can apply an ID-field for a temporary inserted document, if NULL a random string is generated.

Beside these methods, you can:

Access the client and collection objects themselves. In mongolite::mongo() these were hidden attributes, here you can access them directly

Get access to the used parameters: collection (in the return called collectionname to avoid confusion with the collection-object), db (called dbname), url, host, port, verbose and options

Get access to extra slots you've specified with extraSlots, to add more properties and methods.

Get an accompanying RMongo-object, as if you called RMongo::mongoDBConnect(), so you can use for example dbShowCollections(monPlus('MyCol','MyDb')$Rmongo)

They are mostly useful if you want to dig deeper into the methods


Mongolite User Manual
Jeroen Ooms (2014). The jsonlite Package: A Practical and Consistent Mapping Between JSON Data and R Objects. arXiv:1403.2805.

See Also


Dans-labs/MongoPlussed documentation built on May 17, 2019, 6:07 a.m.