Hi,

I'm having trouble implementing a certain table design in GAE.
Consider the following Model:

class Group(db.Model):
        name = db.StringProperty()
        description = db.TextProperty()
        password = db.StringProperty()
        creator = db.ReferenceProperty(User)
        created = db.DateTimeProperty(auto_now=True)

class GroupMembers(db.Model):
        user = db.ReferenceProperty(User)
        group = db.ReferenceProperty(Group)
        admin = db.BooleanProperty()

class Event(db.Model):
        date = db.DateTimeProperty(required=True)
        creator = db.ReferenceProperty(User)
        group = db.ReferenceProperty(Group)
        location = db.StringProperty(required=True)
        title = db.StringProperty(required=True)
        duration = db.IntegerProperty()

Now say I wanted to list all events for all the groups which the user
belongs to. Normally this would be easily solved in SQL:
SELECT e.*
FROM GroupMembers gm, Event e
WHERE gm.group = e.group
     AND gm.user = <some_user_id>

Of course I could get a list of group memberships for a user in one
call, then loop through these groups, get all events for each and
combine in a final list. But that is an ugly way of doing it and would
result in 1 + (N memberships) calls to datastore. Is there any clean
way of solving this in GAE?

Thank you

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Google App Engine" group.
To post to this group, send email to google-appengine@googlegroups.com
To unsubscribe from this group, send email to 
google-appengine+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/google-appengine?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to