How to query Mongo DB using a variable value in RMongo?

547 Views Asked by At

I have to retrieve data from a Mongo DB collection given a particular condition based on a variable value in R. I could find documentation on querying with static values in RMongo. But I could not find how to query using variable values. I tried the below query to retrieve documents from a collection for which the value of the field 'emailId' is equal to that of the variable 'contact'. dbGetQuery(mongo, "name of collection", '{"emailId":"${contact}"}') This query returns 0 rows since it considers '${contact}' as a string. I tried using it without quotes. But that gave error. I found a similar question in stack overflow for rmongodb package. But since I am using RMongo, I need a solution that applies to Rmongo.

0

There are 0 best solutions below