有一个新的版本出来了,但是文档有点缺乏一个工作示例。
集线器票:https://github.com/jbmusso/gremlin-javascript/issues/109
我一直想找个例子来证明这一点。任何帮助都值得赞赏:
gremlin-server: 3.3.2 with config gremlin-server-现代派
npm gremlin lib: 3.3.2
import gremlin from 'gremlin';
import DriverRemoteConnection from 'gremlin/lib/driver/driver-remote-connection';
import { Graph } from 'gremlin/lib/structure/graph';
const graph = new Graph()
const g = graph.traversal().withRemote(new DriverRemoteConnection('ws://localhost:8182/gremlin', { mimeType: 'application/vnd.gremlin-v3.0+json' }));
const fetchById = async (id) => {
const result = await g.V(id).toList()
console.log(result);
}
const addUser = async (name) => {
const newVertex = await g.addV().property('name','marko').property('name','marko a. rodriguez').next()
console.log(newVertex)
}
addUser()
fetchById(0)当前产出:
[]
{ value: null, done: true }发布于 2018-04-19 14:59:16
更新
Gremlin JavaScript现在支持GraphSON3和最新的Gremlin。
工作实例:
const gremlin = require('gremlin');
const Graph = gremlin.structure.Graph;
const DriverRemoteConnection = gremlin.driver.DriverRemoteConnection;获取遍历源(g):
const graph = new Graph();
const connection = new DriverRemoteConnection('ws://localhost:8182/gremlin');
const g = graph.traversal().withRemote(connection);一旦有了遍历源(g),就可以在应用程序中重用它来创建遍历,例如:
// Get the friends' names
const friends = await g.V().has("name","Matt")
.out("knows").values("name").toList();请参阅有关文档的更多信息:https://tinkerpop.apache.org/docs/current/reference/#gremlin-javascript
原始答案
Gremlin JavaScript不支持GraphSON3序列化,这是TinkerPop 3.3+中的默认设置。这会导致您的响应没有得到正确的分析。
我已经在JavaScript GLV:https://issues.apache.org/jira/browse/TINKERPOP-1943中提交了一张支持JavaScript的罚单
同时,作为一种解决办法,您可以将GraphSON2序列化器添加到服务器,方法是在yaml中添加下面一行,在serializers下面
- { className: org.apache.tinkerpop.gremlin.driver.ser.GraphSONMessageSerializerGremlinV2d0, config: { ioRegistries: [org.apache.tinkerpop.gremlin.tinkergraph.structure.TinkerIoRegistryV2d0] }}发布于 2019-02-28 18:49:41
关于未定义问题的read属性“reader”。我又回到了gremlin@3.3.4版本,它运行得很好。
https://stackoverflow.com/questions/49917571
复制相似问题