python - GAE NDB with Endpoints Proto Datastore: filter by ID of reference property -
i created model called building reference model called office. filter buildings officeid in proto rest query (@building.query_method ....)
currently, work office_key property (need enter entity key of office), filter officeid property. ideas on how this?
here's i've tried far:
class building(endpointsmodel): _message_fields_schema = ('id', 'name', 'office') name = ndb.stringproperty(default=none, indexed=true) office_key = ndb.keyproperty(kind=office, required=false) def office_setter(self, value): self.office_key = ndb.key('office', value.id) @endpointsaliasproperty(setter=office_setter, property_type=office.protomodel()) def office(self): return self.office_key.get() class office(endpointsmodel): _message_fields_schema = ('id', 'name', 'created_date') name = ndb.stringproperty(default=none, indexed=true) created_date = ndb.datetimeproperty(auto_now_add=true) @building.query_method(query_fields=('limit', 'order', 'pagetoken', 'office_key'), path='buildings', name='list') def list(self, query): return query
it appears building -> office 1 one relationship (conversely relationship of office -> building many one.
so need store office id in building cached property querying.
then can query buildings specific office id.
alternately query buildings key held in office_key == 'some office key')
Comments
Post a Comment