Crawling the Relationships, In Reverse
You can also crawl the graph in reverse. Although there is no predicate that begins with actor/
that references a subject in credit
collection, we know that actors are referenced in the credit collection.
In order to select all of the credits that belong to an actor, like- for instance ["actor/name", "Tilda Swinton"]
, we can
{
"select": ["*", {"credit/_actor": ["*"]}],
"from": ["actor/name", "Tilda Swinton"]
}
Notice that, we use the relevant predicate name, credit/actor
, but because we are crawling the graph in reverse, we add an, _
in front of actor
. We don't switch the order of the original predicate (actor/credit
or actor/_credit
are both wrong!), but we do need to add the _
.
The results will mirror the shape of our query, and use the credit/_actor
name in showing us our results:
{
"status": 200,
"result": {
"credit/_actor": [
{
"credit/id": "52fe43cdc3a36847f8070be5",
"credit/character": "Karen Crowder",
"credit/order": 2,
"credit/actor": {
"_id": 4316442133756
},
"_id": 4312147268629
},
...
],
"actor/id": 3063,
"actor/name": "Tilda Swinton",
"actor/gender": 1,
"_id": 4316442133756
},
"fuel": 94,
"block": 3373,
"time": "188.42ms"
}
Crawl the Graph in Reverse to Get Movie Information.
The movie collection has a predicate, `movie/productionCompanies`.
Can you select all predicates from the `productionCompany` collection and crawl the graph, in reverse, to get all predicates from each movie?
Remember, we never switch the order of the original predicate.