Created
January 12, 2012 04:14
-
-
Save torufurukawa/1598658 to your computer and use it in GitHub Desktop.
GAE DateTimeProperty index
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from datetime import datetime, timedelta | |
from google.appengine.ext import db | |
class Foo(db.Model): | |
value = db.DateTimeProperty() | |
db.delete(Foo.all()) | |
Foo(value=None).put() | |
Foo(value=datetime.now()).put() | |
Foo(value=datetime.now()).put() | |
print Foo.all().count() # 3 | |
print Foo.all().filter('value >', datetime.now()-timedelta(minutes=1)).count() # 2 | |
print Foo.all().filter('value <', datetime.now()).count() # 3 | |
print Foo.all().filter('value =', None).count() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment