Use dplyr syntax with Mongo DB

Viewed 167

Is it possible, with mongolite or another R package to use dplyr syntax to query a MongoDB? I was thinking something like:

library(mongolite)

# create collection with example data
dmd <- mongo("diamonds")
dmd$insert(ggplot2::diamonds)

Attempt to query using dplyr:

library(dplyr)

premium_diamonds <- dmd %>%
   filter(cut == "Premium",
            price < 1000)

instead of this:

premium_diamonds <- dmd$find('{"cut" : "Premium", "price" : { "$lt" : 1000 } }')

This way I could use my familiarity with dplyr to make complex queries.

0 Answers
Related