2014-12-07 52 views
2

mongoengine有一個集合中查詢對象(文件)的方式有兩種:mongoengine中的物體和過濾器有什麼區別?

Test.object(category="blabla") 

而且

Test.object.filter(category="blabla") 

他們返回相同的結果。但問題是有什麼區別?性能?或者他們只是彼此的別名?

回答

3

沒有區別,one is an alias of the other

def filter(self, *q_objs, **query): 
    """An alias of :meth:`~mongoengine.queryset.QuerySet.__call__` 
    """ 
    return self.__call__(*q_objs, **query) 
相關問題