1
votes

I do have the following datastore model:

class One(db.Model):
  OneDateAdded = db.DateTimeProperty(auto_now_add=True)
  OneTitle= db.StringProperty()
  OneLink= db.LinkProperty()

class Two(db.Model):
  TwoDateAdded = db.DateTimeProperty(auto_now_add=True)
  TwoTitle= db.StringProperty()
  TwoLink= db.LinkProperty()

class Three(db.Model):
  ThreeDateAdded = db.DateTimeProperty(auto_now_add=True)
  ThreeTitle= db.StringProperty()
  ThreeisSomething = db.BooleanProperty(default=False)
  ThreeLink= db.LinkProperty()

and a relation table:

class Relation(db.Model):
      RelationDateAdded = db.DateTimeProperty(auto_now_add=True)
      RelationOne = db.ReferenceProperty(One)
      RelationTwo = db.ReferenceProperty(Two)
      RelationThree = db.ReferenceProperty(Three)

when i tried to implement the PagedQuery Library i came arround the problem that i can´t use some sort of join due to GAE restrictions.

what i wan´t to accomplish is a query on my relationtable where RelationThree.ThreeisSomething = True

Looping over a set of results does not seem to be a solution because the paging would not work (gets 10 results 2 are true 8 are false resulting in a page with only 2 results ..)

is there a way to do something simple like this: (which does not work)

myPagedQuery = paging.PagedQuery(Release.all().filter('Three.ThreeisSomething  =', True), 10)
1
You can't do that in the datastore. Your options are basically to denormalize or to use the new cloud SQL service. - Wooble
i was hoping for another solution but expected this answer.. thank you!! - crimsdings

1 Answers

0
votes

You can use limit and offset documented here. Be wary though, that using them might be expensive - setting on offset of 100 and limit of 10 actually loads 110 records and gives you the last 10.