NDB: filtering by properties on multiple entities

4 views
Skip to first unread message

Rad Apdal via StackOverflow

unread,
May 16, 2017, 9:13:09 PM5/16/17
to gcd-stac...@googlegroups.com

You can denormalize your data and form a Structured property, then run multiple filters on it.

From their samples:

class Address(ndb.Model):
    type = ndb.StringProperty()  # E.g., 'home', 'work'
    street = ndb.StringProperty()
    city = ndb.StringProperty()

class Contact(ndb.Model):
    name = ndb.StringProperty()
    addresses = ndb.StructuredProperty(Address, repeated=True)

def query_contact_multiple_values_in_single_sub_entity():
    query = Contact.query(Contact.addresses == Address(city='San Francisco',
                                                       street='Spear St'))
    return query


Please DO NOT REPLY directly to this email but go to StackOverflow:
http://stackoverflow.com/questions/27191326/ndb-filtering-by-properties-on-multiple-entities/44013923#44013923
Reply all
Reply to author
Forward
0 new messages