2012-07-21 58 views

回答

25

具体而言,您可以使用ComputedProperty自动存储计数,例如,

class X(ndb.Model): 
    prop = ndb.StringProperty(repeated=True) 
    prop_count = ndb.ComputedProperty(lambda e: len(e.prop)) 

X.query(X.prop_count == 2) 
3

在GQL中没有len查询语义,您需要对列表的长度有一个sperate属性并对其进行查询。