[Developers] Query Question

Nick Shapiro nick at metaweb.com
Mon Jul 30 21:28:41 UTC 2007




This query will tell you what companies a person is on the board of:


{
  "q1":{
    "query":[{
      "/business/board_member/board_memberships":[{
        "company":{
          "id":null,
          "name":null
        },
        "optional":true
      }],
      "id":null,
      "name":"Danny Hillis",
      "type":"/common/topic"
    }]
  }
}





To find all the board members of a given company use a reflect, something like this:

{
  "q1":{
    "query":[{
      "/type/reflect/any_reverse":[{
        "member":null,
        "type":"/business/board_membership"
      }],
      "id":null,
      "name":"Metaweb",
      "type":"/common/topic"
    }]
  }
}





To find all the board members of a company and which other companies they are board members of, use the two together:

{
  "q1":{
    "query":[{
      "/type/reflect/any_reverse":[{
        "member":{
          "/business/board_member/board_memberships":[{
            "company":null,
            "optional":true
          }],
          "name":null
        },
        "type":"/business/board_membership"
      }],
      "id":null,
      "name":"Metaweb",
      "type":"/common/topic"
    }]
  }
}


Hope this helps!
Nick




More information about the Developers mailing list