我有一个productpart数据库,其中包含名为“type”的字符串属性。 我要做的是按给定的类型(有时不止一个类型)获取所有产品。在
我尝试过使用GAE过滤器方法,但无法使其正常工作。在
我唯一能做的就是做一个新的数据库GqlQuery每种类型。在
我需要按类型获取每个类型的原因是在客户端以不同的方式显示它们?在
有没有一种方法可以只使用一个查询?在
目前是这样的:
productPartsEntries = {
'color' : db.GqlQuery("SELECT * FROM ProductParts WHERE type = :type", type = 'color'),
'style' : db.GqlQuery("SELECT * FROM ProductParts WHERE type = :type", type = 'style'),
'size' : db.GqlQuery("SELECT * FROM ProductParts WHERE type = :type", type = 'size')
// add more....
}
…弗雷德里克
您可以使用IN运算符。它将创建三个不同的查询,并在场景下将结果组合在一起。参见docs:
相关问题 更多 >
编程相关推荐