gremlin-script
Generate Gremlin scripts with ease.
Works in Node.js and the browser.
Installation
Node.js
$ npm install gremlin-script -S
Browsers
This module works as a CommonJS, AMD module or standalone module (exported globally as GremlinScript
).
API
Instantiate a script object:
var GremlinScript = GremlinScript;var gremlin = ;
Get a reference to the graph:
var Graph = StructureGraph;var g = 'g'; // pass graph identifier/name to the constructor
gremlin.line(String|Helper[, ...parameters])
Adding a raw String line
var gremlin = ; gremlin;gremlinscriptshould;
Adding a raw String line with a bound parameter (printf style)
var gremlin = ; gremlin;gremlinscriptshould;gremlinparamsp0should;
Adding a raw String line with multiple parameters (printf style)
var gremlin = ; gremlin;gremlinscriptshould;gremlinparamsp0should;gremlinparamsp1should;
Adding a line with Graph and Element (Vertex/Edge) helpers
var gremlin = ;var g = 'g'; gremlin;gremlinscriptshould;
Bound parameters when using helpers
Using the bindParameter()
function flags the argument passed to a function as a BoundParameter
. When generating the string, Gremlin-Script will automatically replace such wrapped argument with an automatically generated variable name and push the argument to the gremlin.params
Array.
var bind = bindParameter; var gremlin = ;var g = 'g'; var v1 = gremlin;var v2 = gremlin;gremlin; gremlinscriptshould;gremlinparamsp0nameshould;gremlinparamsp1nameshould;gremlinparamsp2fooshould;
Author
Jean-Baptiste Musso - @jbmusso.
This library was heavily inspired by the great work started by Frank Panetta on gRex. Thanks!
Contributors
https://github.com/gulthor/gremlin-script/graphs/contributors
License
MIT (c) 2014 Jean-Baptiste Musso