map several objects at once ?

19 views
Skip to first unread message

NiL

unread,
Nov 21, 2011, 3:03:56 PM11/21/11
to sqlal...@googlegroups.com
Hi list,

In my use case I have

groups that can include other groups (many to many)
groups can also include users (many to many)

users can 'have feelings' to other users (many to many)

What I want to achieve is :

for a given group, recursively find its sub users
for each of those users, I need the list of the users they ('like' | 'love' | 'hate' ... filter on this criteria)

we discussed the recursive point here : http://www.mail-archive.com/sqlal...@googlegroups.com/msg24742.html

so I manage to have a query that when executed returns a list of all sub users (of class User)
searched group is the starting point (Group object)
content_q = searched_group.get_all_users()

of course, I can iterate on the result of this query, and then create a dict of list (or whatever)
            all_users = set(content_q.all())
            result = {}
            for user in all_users:
                result['user.id']=[]
                    for other in user.my_feelings(feeling='love'):
                        result['user.id'].append((other.id, other.name))



Still as all those tables join, I have a feeling this could be accomplished in a single query
maybe not ?

thanks for any idea

NiL

Wouter Overmeire

unread,
Nov 22, 2011, 9:30:43 AM11/22/11
to sqlal...@googlegroups.com
maybe this helps: querying-with-joins
Reply all
Reply to author
Forward
0 new messages