simpleMongofind: Simplified find in mongo

Description Usage Arguments Value See Also

Description

When querying a mongo-database and getting back a large result-set, most time is spent on casting this to a data.frame.
Especially when this is a intermediate step, it is also often unnecessary. So this function does as little as needed, to save time.
Also useful if for some reason casting to dataframe produces unexpected results.
This function was written before I found out about iterate(), so unclear if it has much use Note that the original mongolite find-function was more object-oriented, and used a mongo connection object, while this function has to be supplied a mongo-collection object (in mongolite, this is stored as an internal pointer). You can get this by connecting using monPlus, and then accessing the 'col' method. Or simply accessing this function with the $simfind-method

Usage

1
2
3
simpleMongofind(moncol, qry = "{}", fields = "{\"_id\" : 0}",
  sort = "{}", skip = 0, limit = 0, handler = NULL, pagesize = 1000,
  verbose = F)

Arguments

moncol

mongo-collection pointer

qry

a query to be supplied to the mongo-database, in json-notation

fields

fields to be retrieved, in json-notation

sort

fields to be sorted on

skip

number of records to skip. Useful together with limit, to continue later

limit

limit to the number of records returned, or 0 for no limit

handler

A function to be applied over the results, e.g. to further filter results. Note that it differs from a handler given to regular "find" in that it is not given a data-frame.

pagesize

size of paging to use, see return value

verbose

emit extra output in the form of a counter

Value

A list of pages with the returns from the mongo DB. To get to a simple list of returns, use unlist(recursive=FALSE)

See Also

mongolite::mongo


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