order by property in reference table.

18 views
Skip to first unread message

sandeep Koduri

unread,
Jun 14, 2011, 5:43:11 AM6/14/11
to google-a...@googlegroups.com
Hello,

i am building a table for registered users faced this issue.

Here is my db structure.

class country(db.model)
      name  =  db.stringProperty()
      currency = db.stringProperty()
      language = db.stringProperty()


class userData(db.model)
     name = db.stringProperty()
     mail   = db.stringProperty()
     country  =  db.referenceProperty(country)

in the form made each column sort able. And also have a filter for countries.


userData.all().order('country.name')

is the kind of query which i am trying to place to get the results.


can any one suggest a way to make this order sort







--
Regards
Sandeep Koduri
Phone: +91- 99 666 02 456
Gtalk: sandeep.koduri | Skype: sandeep.koduri
P Please consider the environment before printing this email 

sergey

unread,
Jun 15, 2011, 2:35:26 AM6/15/11
to Google App Engine
No, you need addition Property in userData for this.
But may be for you work something like this:
entity = country.all().order('name')
for entry in entity
for current_userData in entry.userData_set
#current_userData - is you
userData.all().order('country.name')

Robert Kluin

unread,
Jun 17, 2011, 5:10:58 AM6/17/11
to google-a...@googlegroups.com
If you use this approach and find your pages consume lots of CPU and /
or load very slowly, use Appstats. You might find that you're making
many queries.

Adding the country name property to the user data models will use only
one query, and has the advantage that one cursor can be used to easily
implement a paging solution on the entire query.


Robert

> --
> 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-a...@googlegroups.com.
> To unsubscribe from this group, send email to google-appengi...@googlegroups.com.
> For more options, visit this group at http://groups.google.com/group/google-appengine?hl=en.
>
>

sandeep Koduri

unread,
Jun 17, 2011, 9:22:48 AM6/17/11
to google-a...@googlegroups.com
ya i agree. 

consider also we don't have option to get unique items in a column to populate filter, if we added a string column. 
also we are using reference property to get and show additional properties from this table.

actually i did it the way you said. added a string column for the sort and filter purpose, and another for reference property .
i am trying to show my regret towards the limitations i column while moving some functionality from php to appengine....
Reply all
Reply to author
Forward
0 new messages