游标上的Mongo查询(pymongo)

时间:2018-11-14 01:35:56

标签: pymongo

假设col是一个集合。我想执行这样的查询:

filter1 = col.find({"field1": valueX, "field2": valueY})

现在,我真的不需要filter1,我需要

filter2 = col.find({"field1": valueX, "field2": valueY, "field3": valueZ})
filter3 = col.find({"field1": valueX, "field2": valueY, "field4": valueW})

这当然是条件"field1": valueX, "field2": valueY的两倍。我想做

filter2 = filter1.find({"field3": valueZ})
filter3 = filter1.find({"field4": valueW})

以优化查询。我该如何实现?

0 个答案:

没有答案