Ok, I'll go with the first model. Thanks for the reply!

On Jan 13, 12:53 am, Alexander Kojevnikov <alexan...@kojevnikov.com>
wrote:
> The first variant is faster while the second one requires less
> maintenance if you rename your documents a lot. Both will do the job.
>
> I'd use the first, de-normalised model unless you normally have a lot
> of revisions per document, modify the common document meta-data quite
> often, and the meta-data itself is large (in terms of the number of
> bytes or the number of properties stored).
>
> On Jan 13, 10:33 am, Ecir Hana <ecir.h...@gmail.com> wrote:
>
> > 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