I have a productpart database containing a string property named ‘type’.
What I’m trying to do is to get all products by a given type (sometimes more then one type).
I’ve tried to use GAE filter method but can’t get it to work properly.
The only solution I’ve got working is to make a new db.GqlQuery for each type.
The reason I need to fetch each by type is to display them in different ‘s on the client side?
Is there a way to use just one query for this?
Currently it looks like this :
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....
}
..fredrik
You can use the IN operator. It would create the three different queries and group the results together for you under the scenes. See the docs: