jeroen / mongolite

Fast and Simple MongoDB Client for R
https://jeroen.github.io/mongolite/
284 stars 64 forks source link

Having trouble query based on a list in R using mongolite #169

Open staciewow opened 5 years ago

staciewow commented 5 years ago

I'm using mongolite in R to query data. Now I have a list called "my_list", and I'd like to query a field in mongoDB based on items in my_list.

For example:

my_list = list( "process", "check", "queue" )

values <- mongo$find('{"field" : { "$in" : my_list } }')

Ideally it would return fields equals to "process", "check" and "queue". I've done this in python, but I don't know how to achieve this using R. Please send help... Thanks!

Lsnickels commented 5 years ago

The best way to go about this is using the paste0 function.

See this StackOverflow post on how to use the function in this context.