I have an app on GAE that lets user add\edit posts to any arbitrary path (like a wiki). I am storing all the posts in a single table. The table is structured as follows:
class WikiPosts(db.Model):
path = db.StringProperty(required = True)
content = db.TextProperty(required = True)
date_created = db.DateTimeProperty(auto_now_add = True)
On the home page I want to display the latest post for each path.
My question is similar to this one ( Select first row in each GROUP BY group? ) but the answers involve using join which is not possible in GAE.
I can have a dedicated field to keep track of the latest post for each url but is it possible to do it using gql query?
As of now, I am using this query which returns all the versions of all the wiki posts sorted by their creation time.
db.GqlQuery("SELECT * FROM WikiPosts ORDER BY date_created DESC limit=10")
Since you do not have a unique list of paths, and since GAE does not support the equivalent of SQL’s
SELECT DISTINCT(see here, here, and here), you’ll have toI think option 3 is your best bet, since (as is often the case with GAE), you would be putting into the datastore exactly what you want to get out (i.e., make writes more complicated in favor of quick reads.)