mongolite icon indicating copy to clipboard operation
mongolite copied to clipboard

Having trouble query based on a list in R using mongolite

Open staciewow opened this issue 7 years ago • 1 comments

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!

staciewow avatar Jan 09 '19 21:01 staciewow

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.

Lsnickels avatar Jan 23 '19 15:01 Lsnickels