My model is like this
- Club
- User
- Course
- reference to club (key)
- Session
- reference to Course (key)
- ClubMembership
- reference to club (key)
- reference to user (key)
- CourseSubscription
- reference to course (key)
- reference to user (key)
Now, i want to have all the course
s i'm subscribed to, having as input a club
and a user
what i did is:
courses = Courses(Courses.club == club.key).fetch(keys_only=True)
real_list = []
for course in courses:
if CourseSubscription.get_by_id(user, course):
real_list.append(course)
sessions = Session.query(Session.course.IN(real_list),Session.start_date >= start_date).fetch()
for CourseSubscription i used this https://stackoverflow.com/a/26746542/1257185, this is why i can do the if (yet it's expensive)
is there a better way to do it? at least less expensive. i was thinking of gql, but then i've a list of IN
to do.
probably smt like:
select key from courseSubscription, where course.club = {clubid} and user = {user}
then a ndb_get_multi
to load the query results?
is this possible somehow?