[英]Translate mongo query into python boolean expression
Is there any library that will turn a mongo query into it's equivalent python code:是否有任何库可以将 mongo 查询转换为等效的 Python 代码:
eg turn this:例如转这个:
{name: "foo", age: {$not: {$gt: 20}}}
{名称:“foo”,年龄:{$not:{$gt:20}}}
into:进入:
name == "foo" and not(age > 20)
名称 == "foo" 而不是(年龄 > 20)
Thank you.谢谢你。
I've started a little library named MongoNow: https://github.com/AlexandreMahdhaoui/MongoNow我创建了一个名为 MongoNow 的小库: https : //github.com/AlexandreMahdhaoui/MongoNow
Please check in mongonow/filter_parser.py
how I managed to parse all this queries into python boolean expressions.请检查
mongonow/filter_parser.py
我如何设法将所有这些查询解析为 python 布尔表达式。
Tell me if you have any questions如果您有任何问题,请告诉我
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.