Reputation: 375
I am trying to write R script in which I have to do some operations on mongo database. Therefore, I have a few questions:
How to use double condition? I know how to use single condtion
mongoDB$find(query = '{"id" : { "$in" : ["1","2"]}}')
mongoDB$find(query = '{"date" : { "$in" : "2019-08-09"}}')
How should I connect both conditions in one query? How to write such code?
How to use parameter in mongo code? In my script I will have vector with dynamic number of IDs. How I should write query? I am looking for something like:
VectorWithIDs <- c(1:1000)
mongoDB$find(query = '{"id" : { "$in" : VectorWithIDs}}')
Any Ideas how to solve both problems? Thanks in advance!
Upvotes: 1
Views: 133
Reputation: 121
Just do the query with a "," as a separation token.
For example:
mongoDB$find(query = '{"id" : { "$in" : ["1","2"]}, '': "date" : { "$in" : "2019-08-09"}}'}')
Upvotes: 1