Skip to content

Instantly share code, notes, and snippets.

@sahid
Created August 3, 2010 07:26
Show Gist options
  • Save sahid/505991 to your computer and use it in GitHub Desktop.
Save sahid/505991 to your computer and use it in GitHub Desktop.
## Models.py
class Message (MarkDeleted):
uuid = db.StringProperty (required=True)
owner = db.ReferenceProperty (Actor, collection_name="message_owner", required=True)
target = db.ReferenceProperty (Actor, collection_name="message_target", required=True)
entry = db.ReferenceProperty (Entry, required=True)
reply = db.SelfReferenceProperty ()
label = db.StringProperty (choices=MESSAGE_LABEL, required=True)
readed = db.BooleanProperty (default=False) # Message lu/non lu
trashed = db.BooleanProperty (default=False) # Message Supprimer dans la poubelle ou non
key_template = "%(label)s/%(owner)s/%(uuid)s"
## Index.yaml
- kind: Message
properties:
- name: deleted
- name: label
- name: readed
- name: target
- name: trashed
- name: created
## Query, Why i need a composite index?
query = Message.all ()
query.filter (label =', 'receive')
query.filter ('deleted =', None)
query.filter ('trashed =', False)
query.filter ('target =', actor)
query.filter ('readed =', False)
print query.count ()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment