gql

Can a GQL query execute an order by over two or more kinds?

I have two entity kinds in my python GAE app - both with similar attributes - and I'd like to query both lists and order the result according to an attribute common to both kinds. So something along the lines of: db.GqlQuery("SELECT * FROM Video1, Video2 ORDER BY views DESC").fetch(1000) Can I do this in GQL directly? ...

Minimize subqueries with IN queries on AppEngine (python)

Is there any clever way to avoid making a costly query with an IN clause in cases like the following one? I'm using Google App Engine to build a Facebook application and at some point I (obviously) need to query the datastore to get all the entities that belong to any of the facebook friends of the given user. Suppose I have a couple o...

Getting The Most Recent Data Item - Google App Engine - Python

I need to retrieve the most recent item added to a collection. Here is how I'm doing it: class Box(db.Model): ID = db.IntegerProperty() class Item(db.Model): box = db.ReferenceProperty(Action, collection_name='items') date = db.DateTimeProperty(auto_now_add=True) #get most recent item lastItem = box.items.order('-date')[0]...