Reputation: 1
I have two models:
class Author(ndb.Model):
email = ndb.StringProperty(indexed=true)
class Course(ndb.Model):
student = ndb.StructuredProperty(Author, repeated=True)
I am trying to query Course to find where a student's email matches that of user.email_address. Is it possible to structure this as a single query?
Upvotes: 0
Views: 371
Reputation: 977
You have to query by using Author object as a filter
query = Course.query(Course.student.email == '[email protected]')
But this query is correct only if you are querying for a single property. Official documentation suggests to use following filter
query = Course.query(Course.student == Student(email='[email protected]'))
See https://cloud.google.com/appengine/docs/standard/python/ndb/queries#filtering_structured_properties for more information
Upvotes: 2