Hello,
what is the preferred way of retrieving the latest revision of a
document?
(The 'name' doesn't change across the revisions.)

1:
class Document(db.Model):
  name = db.StringProperty()
  revision = db.IntegerProperty()
  content = db.TextProperty()

latest = Document.all().filter('name =', some_name).order('-
revision').get()

2:
class Document(db.Model):
  name = db.StringProperty()

class Revision(db.Model):
  document = db.ReferenceProperty(Document,
collection_name='revisions')
  revision = db.IntegerProperty()
  content = db.TextProperty()

document = Document.all().filter('name =', some_name).get()
latest = document.revisions.order('-revision').get() [1]

3:
something different altogether?

[1] Is it ok to call .get() for the second time?

Thanks in advance!

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

Reply via email to