我有一个数据库集合(名为 fols),如下所示:
{'followers':
{
'123':1
'123':2
'123':3
}
}
如果我运行查询(使用 pymongo):
cursor = fols.find()
cursor.count()
>>3
工作正常。现在:
cursor = fols.find({'followers':{'123':1}})
cursor.count()
>>1
再次工作正常。但如果我尝试:
cursor = fols.find({'followers':{'123':{'$exists': True}}})
cursor.count()
>> 0
即使有 3 条记录,它也会返回 0。