The simplest RxJS wrapper around gremlin lib
Rough implementation of rxified wrapper of gremlin lib.
Usage examples
const { tap } = require('rxjs/operators');
const RxGremlin = require('@rough/rx-gremlin');
const gremlin = new RxGremlin('ws://gremlin-server:8182/gremlin');
gremlin.traverse(g => g.V().hasLabel('Person').valueMap(true).next())
.pipe(
tap(({ value }) => console.log(value))
)
// .subscribe ...
Also, each g
instance has handy shortcuts as follows:
g.T = gremlin.process.t;
g.G = gremlin.process.statics;
g.P = gremlin.process.P;
g.TextP = gremlin.process.TextP;
g.C = gremlin.process.cardinality;
g.O = gremlin.process.order;
What can be used right away without additional imports:
// ...
g => g.V()
.has(g.T.label, g.P.within('Entity', 'Person'))
.has('description', g.P.not(g.TextP.containing(['word1', 'word2'])))
.where(g.G.not(g.G.outE('parent')))
.order().by('updated_at', g.O.desc)
.valueMap(true)
.toList()
// ...
Configuration
For connection options see official DriverRemoteConnection class. You may pass such options as the second parameter of the constructor, e.g. in order to switch from default GraphSON to GraphBinary protocol you would do the following:
new RxGremlin('ws://gremlin-server:8182/gremlin', { mimeType: 'application/vnd.graphbinary-v1.0' });