I am trying to combine a polymodel class withe an NBD class. Any help in clarifying the "best" way to do this would be great given the following problem.
I have a polymodel of fruit (Fruit -> Tree-Bearing -> Apples -> Granny Smith
- as an example of a polymodel hierarchy), I want to store it in a ndb.Model that is called Diet. So Obviously I have a category for Fruit, a category for Vegetable, etc. How should this be constructed?
so far I have:
class Diet(ndb.Model):
nameOfDiet = ndb.StringProperty()
fruit = ndb.StructuredProperty(Fruit)
vegetable = ndb.StructuredProperty(Vegetable)
problem with this - as I think I am reading it correctly, is that the fruit and vegetable objects of diets is "non-queryable." I obviously want users to be able to search for diets that match their specific fruit. I also want to take advantage of the caching capability of ndb. How can I query for fruit efficiently such that if I want all granny smith diets I can get it without returning any that have a value of none. Plus, is it possible to do poly model with NDB at all? If not, how would I change the structure of fruit to A) match what I want and B) be at least nominally efficient?
Thanks so much! Jon