Home > appengine > appengine – SELECT using OR clause – alternative

appengine – SELECT using OR clause – alternative

Appengine does not support SELECT using an OR clause. There are a number of options out there and this is one of them. The Kind I am using this on will not have alot of data and I am hoping (fingers crossed) that it will not cause a performance issue later on.

Filter, StringListProperty.

from googleappengine.ext import db

class Post(db.Model):
    author = db.StringProperty()
    category = db.StringListProperty()

post = Post(author="Sam", category=['bash', 'emacs','lisp'])
post = Post(author="Peter", category=['bash', 'appengine'])
post = Post(author="Ken", category=['mail', 'django','irc', 'sql'])

results = Post.all().filter('category = ', 'bash')

for item in results:
    print item.author, item.category

You would then get the following two items.

Sam [u'bash', u'emacs', u'lisp']
Peter [u'bash', u'appengine']


Categories: appengine
  1. No comments yet.
  1. No trackbacks yet.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.

%d bloggers like this: