-->

如何操作所有的mongoengine使用和icontains结合(How to combine th

2019-10-16 22:57发布

对于mongoengine,有运营商allicontains 。 但我怎么能结合他们的使用情况如何?

假设每个项目,我只是想配合icontains但不能exact ? 我试图用正则表达式。 我的作品,但不幸的是,如果我有1个多它会打破Q在mongoengine的查询集。 因为它会尝试deepcopypattern对象,但不幸的是pattern的对象不能被深深复制。

Answer 1:

其实,我建议使用pymongo ,通过安装easy_install pymongo ,在pymongo,你可以尝试:

db.collections.find({'$and':[
    {'field A':re.compile('your pattern')},
    {'$ne':{'field A':'not exact word'}}
]})

在这里, $ne$and原产蒙戈DB运营商,你会发现更多的细节MongoDB的advnace查询



文章来源: How to combine the usage of operator all and icontains for mongoengine