You want something like (Where N is some number):

"Select * from myModel Where Prop1 + Prop2 < N"

No do that here impossible in GAE.

Just change the "question_ttl" property into "expiration_timestamp" (or
maybe us a nice short prop name) and calculate that future expiration date
when the entity is created (and recalculate it if 'question_ttl' ever
changes).

So you just need to query for:

WaitingQuestion.all().filter('expiration_timestamp <', datetime.now())

On Wed, Dec 15, 2010 at 11:04 AM, Lenny Rachitsky <lenny...@gmail.com>wrote:

> Just noticed there is a small typo in the code above, the query should
> be hitting "WaitingQuestions", not "WaitingAnswer".
>
> On Dec 15, 11:00 am, Lenny Rachitsky <lenny...@gmail.com> wrote:
> > Does App Engine allow self-referencing queries, where I use a property
> > of an entity as part of the filter? For example, below I am attempting
> > to use the "question_ttl" property to filter questions that are
> > expired (e.g. older than "question_ttl" minutes). I'm attempting to
> > avoid having to iterate through the entire batch. Is this possible? I
> > attempted to use "self" below, but that doesn't work.
> >
> > --------------------
> > class WaitingQuestions(db.Model):
> >     question = db.TextProperty()
> >     question_ttl = db.IntegerProperty()
> >     timestamp = db.DateTimeProperty(auto_now=True, auto_now_add=True)
> >
> >     @staticmethod
> >     def get_expired_questions():
> >         return WaitingAnswer.all().filter('timestamp < ',
> > datetime.now() - timedelta(minutes=self.question_ttl))
> > --------------------
> >
> > Any help would be much appreciated. Thank you in advance,
> > Lenny
>
> --
> 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-appeng...@googlegroups.com.
> To unsubscribe from this group, send email to
> google-appengine+unsubscr...@googlegroups.com<google-appengine%2bunsubscr...@googlegroups.com>
> .
> For more options, visit this group at
> http://groups.google.com/group/google-appengine?hl=en.
>
>

-- 
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-appeng...@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