R. Martin R. Martin - 20 days ago 4x
R Question

Correct syntax with IN condition on a find() query in mongolite

I am trying to use an IN condition to query with the mongolite package. I can get the query to work if I use the mongo console based on this page:
https://docs.mongodb.com/manual/reference/operator/query/in/#op._S_in. I've tried variations on the following in my R code, but either end up with 0 results or a syntax error:

aaContDF <- mongoBirdData$find('{ "aircraftAirlineOperator": { "$in":
fields = '{"recordId":1, "originState":1,

With error message:

Error: Invalid JSON object: { "aircraftAirlineOperator": { "$in":

The queries I've worked with have been AND conditions, haven't encountered any OR scenarios yet. Thank you.


Figured it out by being more patient and adding pieces step-by-step:

aaContDF <- mongoBirdData$find('{ "aircraftAirlineOperator" : 
                           { "$in" : [ "AMERICAN AIRLINES",
                           "CONTINENTAL AIRLINES"]  } }',
                           fields = '{"recordId":1, "originState":1,