The equivalent for field.belongs('A','B','C') is like field=='A'||
field=='B'||field=='C' on GAE you can do AND (&&) but not do OR (||),
so it can be done using 3 separate queries and append/unique the
results. On GAE you need to think in terms of what query is cheap at
request time, and merging result sets in memory is not cheap, so it
should be done offline using the task queue, and the result should
just be fetched at request time.
This presentation mentions some GAE best practices like avoiding SQL
joins: http://ru.ly/mc
Using a listproperty to store the groups would save you a join, but
you still need to do 1 query for each group.
Robin
On Oct 19, 1:26 am, william wang <[email protected]> wrote:
> Hi everone,
>
> I am a newbie to w2p and gae. As a startup, i develop with the sqlite
> db, now i am trying to run it GaeLauncher.
> Belongs break, it confused me some time to find out gql doesn't
> implement it yet.
> Is it possible to add some more obvious exception string into the gql?
> Like "belongs() is not supported in GAE yet", so newbies like me will
> know what's going on immediately.
>
> And my question is:
> my db.py:
>
> db.define_tables('groups', Field('name'))
> db.define_tables('posts', Field('group_id', db.groups))
> db.define_tables('subscribes', Field('group_id', db.groups), Filed
> ('user_id', db.auth_user))
>
> What I am trying to do is find out all the latest posts in my
> subscribed groups (like twitter home timeline)
>
> # the codes doesn't work in gae
> # user_subscribes = db(db.subscribes.user_id==auth.user.id)._select
> (db.subscribes.group_id)
> # posts = db(db.posts.group_id.belongs(user_subscribes)).select
> (orderby=~db.posts.created_at)
>
> Can you guys help me out with a equal solution for GAE?
>
> Thanks,
> William
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"web2py-users" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/web2py?hl=en
-~----------~----~----~----~------~----~------~--~---