[Developers] mediated properties
Nick Thompson
nix at metaweb.com
Thu Jun 28 20:09:38 UTC 2007
in general, i don't think your question has a well-defined answer -
there's no reason for the system to believe that
/business/employment_tenure/company is more relevant than
/business/employment_tenure/title, for example. you could be looking
for a list of people at a particular company, in which case the job
title would more interesting.
so, you might rule out /business/employment_tenure/person from context
as chris described, but that doesn't determine a unique "other side".
that's the nature of compound value types - if a relationship only
had two sides, it would probably be modeled as a single link instead
of being mediated by a compound value object.
nick
Steve Sak wrote:
> So, if I'm looking at /people/person/employment_history how would I
> determine that the relevant property is
> /business/employment_tenure/company?
>
>
>
> Alec Flett wrote:
>> I want to add that checking by is only valid if you know you're coming
>> in and out on the same property (as is the case with marriage) - if
>> the properties are different, you need to look at master/reverse
>> properties because you can imagine a director who also produced a
>> movie - if you were just going by ids, looking at the relationship of
>>
>> "Who is the /director/ of this movie /produced by/ Martin Scorsese?" -
>> you might get Martin Scorsese back, but that doesn't mean that
>> "director" is the reverse of "produced by".
>>
>> Alec
>>
>> Christopher R. Maden wrote:
>>> Steve Sak wrote:
>>>
>>>> To restate the question: given a mediator object how do I determine
>>>> which property is the one it's mediating? For example, type A has a
>>>> mediator M that has a bunch of properties mediates between A and another
>>>> object. How do I determine which property of M is the one that points
>>>> to the other object being mediated?
>>>>
>>> Mediators, or compound value types, are not especially different from
>>> any other type; the UI treats them a little differently, but that’s it.
>>>
>>> But I think you are asking about instances rather than types, correct?
>>> In other words, Arnold Schwarzenegger connects to a marriage, and that
>>> marriage connects to two people, both Arnold Schwarzenegger and Maria
>>> Shriver. How can you tell which of the spouses is the one you started from?
>>>
>>> The only way to do that, really, is by looking at the IDs.
>>>
>>> {
>>> "query": {
>>> "id": null,
>>> "name": "Arnold Schwarzenegger",
>>> "spouse_s": [
>>> {
>>> "spouse": [
>>> {
>>> "id":null,
>>> "name":null
>>> }
>>> ],
>>> "type":"/people/marriage"
>>> }
>>> ],
>>> "type":"/people/person"
>>> }
>>> }
>>>
>>> {
>>> "result": {
>>> "spouse_s": [
>>> {
>>> "spouse": [
>>> {
>>> "id": "#9202a8c04000641f80000000001da07e",
>>> "name": "Maria Shriver"
>>> },
>>> {
>>> "id": "#9202a8c04000641f8000000000006567",
>>> "name": "Arnold Schwarzenegger"
>>> }
>>> ],
>>> "type": "/people/marriage"
>>> }
>>> ],
>>> "type": "/people/person",
>>> "id": "#9202a8c04000641f8000000000006567",
>>> "name": "Arnold Schwarzenegger"
>>> }
>>> }
>>>
>>> You can see that one of the spouses in the marriage has the same ID as
>>> the person with whom you started, and that the other is different.
>>>
>>> Unfortunately, there’s not really an automatic way to say “get all of
>>> the values of these properties except the ones that point back to the
>>> parent within the scope of this query.”
>>>
>>> HTH,
>>> Chris
>>>
>
More information about the Developers
mailing list