擅长:python、mysql、java
<p>来自MongoDB文档的<a href="http://docs.mongodb.org/manual/reference/operator/query/and/" rel="nofollow">^{<cd1>}</a>用法。在</p>
<blockquote>
<p>MongoDB provides an implicit AND operation when specifying a comma separated list of expressions. Using an explicit AND with the $and operator is necessary when the same field or operator has to be specified in multiple expressions.</p>
</blockquote>
<p>您只需要对重复的字段名使用<code>$and</code>运算符。<code>humsaver.Disease</code>、<code>humsaver.dbSNP</code>和{<cd5>}的条件将是隐式的。(尽管使用<code>$and</code>将得到相同的结果)。在</p>
<pre><code>test_3.find(
{"humsavar.Disease":
{'$and': [
{"$ne": u'-'},
{ "$ne":None},
{ "$exists": True}
]}
},
{"humsavar.dbSNP":
{'$and':[
{"$ne": u'-'},
{ "$ne": None},
{ "$exists": True}
]},
},
{"humsavar":True, "_id": False}
).count()
</code></pre>