jeroen / mongolite

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

syntax for variable queries #199

Open bastienchassagnol opened 4 years ago

bastienchassagnol commented 4 years ago

Hello @jeroen , thanks for your package, but about introducing variable, and for ease issues for huge queries, you might consider the Python syntax (example: collection.find({'Synonyms': match_term}, {'_id': 0})), hiding the underlying json structure into your own code.

As instance, I wanted to query a MongoDb gene collection, so that I could update my genes with the newest terms.

jeroen commented 4 years ago

I don't understand what you mean. The find() method allows you to query by syntax?

bastienchassagnol commented 4 years ago

For example, you can compare both syntaxes:

I don't know how they exactly do in the pymongo package, but I personally found second syntax easier to use, instead of coercing the expression into a json format. Besides, (I don't know if possible in R), but they automatically detect regex expression when performing queries.

Another interesting feature (I don't know if existing in your package), you can simply accessing a specific collection of a database with the . marking an object in Python:collection = name_db.name_collection, once you open the connection with the database.

I hope I was clear, and nevermind, your package reveals useful.