Skip to content

Commit e4b44b4

Browse files
committed
Implemented traversal.
1 parent 567ea37 commit e4b44b4

File tree

3 files changed

+42
-0
lines changed

3 files changed

+42
-0
lines changed

README.md

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -529,6 +529,14 @@ Retrieves a list of all incoming edges of the document with the given *documentH
529529

530530
Retrieves a list of all outgoing edges of the document with the given *documentHandle*.
531531

532+
#### edgeCollection.traversal(startVertex, [opts,] callback)
533+
534+
Performs a traversal starting from the given *startVertex* and following edges contained in this edge collection.
535+
536+
See [the HTTP API documentation](https://docs.arangodb.com/HttpTraversal/README.html) for details on the additional arguments.
537+
538+
Please note that while *opts.filter*, *opts.visitor*, *opts.init*, *opts.expander* and *opts.sort* should be strings evaluating to well-formed JavaScript functions, it's not possible to pass in JavaScript functions directly because the functions need to be evaluated on the server and will be transmitted in plain text.
539+
532540
## Graph API
533541

534542
### graph.drop([dropCollections,] callback)
@@ -573,6 +581,14 @@ Removes the edge definition with the given *definitionName* form the graph.
573581

574582
If *dropCollection* is set to `true`, the edge collection associated with the definition will also be deleted from the database.
575583

584+
#### graph.traversal(startVertex, [opts,] callback)
585+
586+
Performs a traversal starting from the given *startVertex* and following edges contained in any of the edge collections of this graph.
587+
588+
See [the HTTP API documentation](https://docs.arangodb.com/HttpTraversal/README.html) for details on the additional arguments.
589+
590+
Please note that while *opts.filter*, *opts.visitor*, *opts.init*, *opts.expander* and *opts.sort* should be strings evaluating to well-formed JavaScript functions, it's not possible to pass in JavaScript functions directly because the functions need to be evaluated on the server and will be transmitted in plain text.
591+
576592
### VertexCollection API
577593

578594
Graph vertex collections extend the *Collection* API with the following methods.

lib/collection.js

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -247,6 +247,19 @@ extend(EdgeCollection.prototype, {
247247
},
248248
outEdges: function (vertex, callback) {
249249
return this._edges(vertex, 'out', callback);
250+
},
251+
traversal: function (startVertex, opts, callback) {
252+
if (typeof opts === 'function') {
253+
callback = opts;
254+
opts = undefined;
255+
}
256+
this._api.post('traversal', extend({}, opts, {
257+
startVertex: startVertex,
258+
edgeCollection: this.name
259+
}), function (err, data) {
260+
if (err) callback(err);
261+
else callback(null, data.result);
262+
});
250263
}
251264
});
252265

lib/graph.js

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,19 @@ extend(Graph.prototype, {
6868
dropCollection = undefined;
6969
}
7070
this._gharial.delete('edge/' + definitionName, {dropCollection: dropCollection}, callback);
71+
},
72+
traversal: function (startVertex, opts, callback) {
73+
if (typeof opts === 'function') {
74+
callback = opts;
75+
opts = undefined;
76+
}
77+
this._api.post('traversal', extend({}, opts, {
78+
startVertex: startVertex,
79+
graphName: this.name
80+
}), function (err, data) {
81+
if (err) callback(err);
82+
else callback(null, data.result);
83+
});
7184
}
7285
});
7386

0 commit comments

Comments
 (0)