1
0
Fork 0
arangodb/Documentation/Examples/RestTraversalVisitorExpande...

112 lines
3.1 KiB
Plaintext

shell> curl -X POST --data-binary @- --dump - http://localhost:8529/_api/traversal <<EOF
{"startVertex":"persons/alice","graphName":"knows_graph","expander":"var connections = [ ];if (vertex.name === \"Alice\") {config.datasource.getInEdges(vertex).forEach(function (e) {connections.push({ vertex: require(\"internal\").db._document(e._from), edge: e});});}if (vertex.name === \"Eve\") {config.datasource.getOutEdges(vertex).forEach(function (e) {connections.push({vertex: require(\"internal\").db._document(e._to), edge: e});});}return connections;"}
EOF
HTTP/1.1 200 OK
content-type: application/json; charset=utf-8
{
"result" : {
"visited" : {
"vertices" : [
{
"_id" : "persons/alice",
"_key" : "alice",
"_rev" : "968094603",
"name" : "Alice"
},
{
"_id" : "persons/eve",
"_key" : "eve",
"_rev" : "968946571",
"name" : "Eve"
},
{
"_id" : "persons/bob",
"_key" : "bob",
"_rev" : "968291211",
"name" : "Bob"
}
],
"paths" : [
{
"edges" : [ ],
"vertices" : [
{
"_id" : "persons/alice",
"_key" : "alice",
"_rev" : "968094603",
"name" : "Alice"
}
]
},
{
"edges" : [
{
"_id" : "knows/969798539",
"_key" : "969798539",
"_rev" : "969798539",
"_from" : "persons/eve",
"_to" : "persons/alice"
}
],
"vertices" : [
{
"_id" : "persons/alice",
"_key" : "alice",
"_rev" : "968094603",
"name" : "Alice"
},
{
"_id" : "persons/eve",
"_key" : "eve",
"_rev" : "968946571",
"name" : "Eve"
}
]
},
{
"edges" : [
{
"_id" : "knows/969798539",
"_key" : "969798539",
"_rev" : "969798539",
"_from" : "persons/eve",
"_to" : "persons/alice"
},
{
"_id" : "knows/969995147",
"_key" : "969995147",
"_rev" : "969995147",
"_from" : "persons/eve",
"_to" : "persons/bob"
}
],
"vertices" : [
{
"_id" : "persons/alice",
"_key" : "alice",
"_rev" : "968094603",
"name" : "Alice"
},
{
"_id" : "persons/eve",
"_key" : "eve",
"_rev" : "968946571",
"name" : "Eve"
},
{
"_id" : "persons/bob",
"_key" : "bob",
"_rev" : "968291211",
"name" : "Bob"
}
]
}
]
}
},
"error" : false,
"code" : 200
}