Следующие обратные ссылки неизвестных видов в НБД

Я нахожусь в процессе написания моего первого веб-сервиса RESTful поверх GAE и среды выполнения Python 2.7; Я начал использовать блестящий новый API ndb от Guido.

Однако я не уверен, как решить конкретный случай без неявной функции обратной ссылки исходного API базы данных. Если пользовательский агент запрашивает определенный ресурс и эти ресурсы удалены на 1 градус:

хост / API / тип / идентификатор? Глубина = 2

What's the best way to discover a related collection of entities from the "one" in a one-to-many relationship, given that the kind of the related entity is unknown at development time?

I'm unable to use a replacement query as described in a previous SO inquiry due to the latter restriction. The fact that my model is definable at runtime (and therefore isn't hardcoded) prevents me from using a query to filter properties for matching keys.

Ancestor and other kindless queries are also out due to the datastore limitation that prevents me from filtering on a property without the kind specified.

До сих пор единственная идея, которую я имел (помимо возврата к API db), состоит в том, чтобы использовать транзакцию между группами для записи моей собственной ссылки на "one", либо путем обновления ndb.StringProperty (repeat = True) содержащий все связанные виды, когда вводится сущность нового вида, или просто ведение списка ключей на «одном» ndb.KeyProperty (repeat = True) каждый раз, когда связано "много" сущность записывается в хранилище данных.

Я надеюсь, что кто-то более опытный, чем я, может предложить лучший подход.

Учитывая предложение jmort253, я попытаюсь дополнить мой вопрос конкретным примером, адаптированным из документов:

class Contact(ndb.Expando):
    """ The One """

    # basic info
    name = ndb.StringProperty()
    birth_day = ndb.DateProperty()

    # If I were using db, a collection called 'phone_numbers' would be implicitly 
    # created here.  I could use this property to retrieve related phone numbers 
    # when this entity was queried.  Since NDB lacks this feature, the service 
    # will neither have a reference to query nor the means to know the 
    # relationship exists in the first place since it cannot be hard-coded.  The
    # data model is extensible and user-defined at runtime; most relationships
    # will be described only in the data, and must be discoverable by the server.
    # In this case, when Contact is queried, I need a way to retrieve the
    # collection of phone numbers.

    # Company info.
    company_title = ndb.StringProperty()
    company_name = ndb.StringProperty()
    company_description = ndb.StringProperty()
    company_address = ndb.PostalAddressProperty()

class PhoneNumber(ndb.Expando):
    """ The Many """

    # no collection_name='phone_numbers' equivalent exists for the key property
    contact = ndb.KeyProperty(kind='Contact')
    number = ndb.PhoneNumberProperty()

Ответы на вопрос(2)

Ваш ответ на вопрос