Closed Ploulack closed 6 years ago
What kind of handlers? Which function?
the 'find' method as in:
db$find('{}', handler = )
Ah OK. It's a callback function, similar to the handler argument in jsonlite::stream_in. If specified, it will be called many times, each time with a subset of the results.
Thank you. Got it. So I can apply my handler function on each page which' size depends on my pagesize parameter. Correct? Talking about this, where could I find more info on the pagesize parameter (still the find method)? Is it per documents found? per actual json lines?
In the mongolite $find
method it is the number of documents per page. Just try this:
con <- mongo("mtcars", url = "mongodb://readwrite:test@ds043942.mongolab.com:43942/jeroen_test")
con$insert(mtcars)
handler <- function(x){
cat("found", nrow(x), "documents!\n")
print(x)
}
con$find("{}", handler = handler, pagesize = 5)
con$drop()
Great thank you! :) I've just made my first handler for find. Life feels so much modular suddenly :)
Also have a look at the iterate
method which is similar but more low-level (per document).
Hello,
thank you for the work, I use it everyday :) I'd like to learn more about handlers, and couldn't find anything in the documentation. Could you share a pointer? Thank you.