我有以下对象:
class Address(ndb.Model):
type = ndb.StringProperty() # E.g., 'home', 'work'
street = ndb.StringProperty()
city = ndb.StringProperty()
class Friend(ndb.Model):
first_name = ndb.StringProperty() # E.g., 'home', 'work'
last_name = ndb.StringProperty()
class Contact(ndb.Model):
name = ndb.StringProperty()
addresses = ndb.StructuredProperty(Address, repeated=True)
friends = ndb.StructuredProperty(Friend, repeated=True)
现在为了优化查询的性能,我想构建一个查询,该查询将返回所有联系人,仅包括属性名称和地址。
所以我建立了一个这样的投影查询:
qry = Contact.query(projection=['name', 'addresses'])
触发此错误:
InvalidPropertyError:结构化属性地址需要子属性
知道如何进行包含结构化属性的投影查询吗?