3 ms·
This is definitely possible to do in reverse. Unfortunately, the thing that makes the Python-MongoDB translation so easy is that Python provides utilities to pa
by juliusgeo 3y ago
This is definitely possible to do in reverse. Unfortunately, the thing that makes the Python-MongoDB translation so easy is that Python provides utilities to parse and lex the Python source code. If you were to translate from MongoDB back to Python, you would have to construct the AST yourself. You can use `ast.unparse` to convert a Python AST into Python source code. The main issue that I find with aggregations is that they are prefix rather than infix notation. Converting them to infix perhaps could make them easier to understand as well?
- mattbillenstein 3y agoHmm, yeah, there is probably some C++ code in the mongodb source tree you could use to parse the aggregations. This whole app needs a refactor anyway - probably just live with it until then.