Search code examples
pythongoogle-app-enginecollectionsreferenceproperty

How can I get a collection of collection


I have these models:

class Country(db.Model):
    name    = db.StringProperty()
    code    = db.StringProperty()

class Course(db.Model):
    name          = db.StringProperty()
    description   = db.StringProperty()
    country       = db.ReferenceProperty(Country, collection_name='courses')

class Application():
    status    = db.StringProperty()
    course    = db.ReferenceProperty(Course, collection_name='applications')

One country has many courses, and one course has many applications. So how can I get a query with all the applications from a country? Is it even possible?


Solution

  • The GAE datastore is not a relational model. You cannot do joins. You would need to iterate through each course to get its applications.