tinkerpop-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dkupp...@apache.org
Subject [10/24] tinkerpop git commit: Improve JavaScript Gremlin documentation
Date Tue, 24 Apr 2018 15:21:19 GMT
Improve JavaScript Gremlin documentation

Several fixes to the JavaScript GLV documentation:
- Use 'gremlin' package name
- Include information regarding Promises
- Fix method names

Project: http://git-wip-us.apache.org/repos/asf/tinkerpop/repo
Commit: http://git-wip-us.apache.org/repos/asf/tinkerpop/commit/e08651b9
Tree: http://git-wip-us.apache.org/repos/asf/tinkerpop/tree/e08651b9
Diff: http://git-wip-us.apache.org/repos/asf/tinkerpop/diff/e08651b9

Branch: refs/heads/TINKERPOP-1628
Commit: e08651b946e936579db538f9114dd1c5c9079bcb
Parents: 2591302
Author: Jorge Bay Gondra <jorgebaygondra@gmail.com>
Authored: Mon Apr 23 10:26:36 2018 +0200
Committer: Jorge Bay Gondra <jorgebaygondra@gmail.com>
Committed: Mon Apr 23 10:26:36 2018 +0200

 docs/src/reference/gremlin-variants.asciidoc | 47 +++++++++++++++++------
 1 file changed, 36 insertions(+), 11 deletions(-)

diff --git a/docs/src/reference/gremlin-variants.asciidoc b/docs/src/reference/gremlin-variants.asciidoc
index d929b3c..7a85ab1 100644
--- a/docs/src/reference/gremlin-variants.asciidoc
+++ b/docs/src/reference/gremlin-variants.asciidoc
@@ -458,17 +458,24 @@ their Java counterparts which makes it possible to use lambdas with
 == Gremlin-JavaScript
 image:gremlin-js.png[width=130,float=right] Apache TinkerPop's Gremlin-JavaScript implements
Gremlin within the
-JavaScript language. It targets Node.js runtime and can be used on different operating systems
on any Node.js 4 or
+JavaScript language. It targets Node.js runtime and can be used on different operating systems
on any Node.js 6 or
 above. Since the JavaScript naming conventions are very similar to that of Java, it should
be very easy to switch
 between Gremlin-Java and Gremlin-JavaScript.
-npm install gremlin-javascript
+npm install gremlin
 The Gremlin-JavaScript provides `GraphTraversalSource`, `GraphTraversal`, and `__` which
mirror the respective classes
 in Gremlin-Java. The `GraphTraversalSource` requires a RemoteConnection implementation in
order to communicate with
+const gremlin = require('gremlin');
+const Graph = gremlin.structure.Graph;
+const DriverRemoteConnection = gremlin.driver.DriverRemoteConnection;
 A traversal source can be spawned with `RemoteStrategy` from an empty `Graph`.
@@ -489,27 +496,45 @@ IMPORTANT: Gremlin-JavaScript’s `Traversal` base class supports the
standard G
 === RemoteConnection Submission
-Very similar to Gremlin-Python and Gremlin-Java, there are various ways to submit a traversal
to a
-`RemoteConnection` using terminal/action methods off of `Traversal`.
+In a similar way as in other GLVs, there are various ways to submit a traversal to a
+`RemoteConnection` using terminal/action methods off of `Traversal`. Given that I/O operations
in Node.js are
+asynchronous by default, this terminal methods return a `Promise`.
-* `Traversal.next()`
-* `Traversal.toList()`
+* `Traversal.toList()`: Returns a `Promise` with an `Array` as result value.
+* `Traversal.next()`: Returns a `Promise` with a `{ value, done }` tuple as result value,
according to the
+link:https://github.com/tc39/proposal-async-iteration[async iterator proposal].
+* `Traversal.iterate()`: Returns a `Promise` without a value.
+For example:
+  .then(names => console.log(names));
+You can `await` the promises if you are using `async` functions.
+const names = await g.V().hasLabel('person').values('name').toList();
 === Static Enums and Methods
 Gremlin has various tokens (e.g. `t`, `P`, `order`, `direction`, etc.) that are represented
in Gremlin-JavaScript as
-These can be used analogously to how they are used in Gremlin-Java.
-g.V().hasLabel("person").has("age",P.gt(30)).Order().By("age", order.decr).toList()
+g.V().hasLabel('person').has('age', P.gt(30)).order().by('age', order.decr).toList()
 These objects must be required manually from the `process` namespace:
-const gremlin = require('gremlin-javascript');
+const gremlin = require('gremlin');
 const P = gremlin.process.P;
@@ -517,7 +542,7 @@ Finally, using static `__` anonymous traversals like `__.out()` can be
-const gremlin = require('gremlin-javascript');
+const gremlin = require('gremlin');
 const __ = gremlin.process.statics;

View raw message