【发布时间】:2020-10-18 18:58:06
【问题描述】:
我正在用 Lamda Nodejs12.x 编写代码
我想更新到不被弃用的连接方式
const gremlin = require('gremlin');
const DriverRemoteConnection = gremlin.driver.DriverRemoteConnection;
const traversal = gremlin.process.AnonymousTraversalSource.traversal;
const clusterEndpoint = process.env.CLUSTER_ENDPOINT;
const port = process.env.CLUSTER_PORT;
const connectionStrArray = [];
connectionStrArray.push("wss://");
connectionStrArray.push(clusterEndpoint);
connectionStrArray.push(":");
connectionStrArray.push(port.toString());
connectionStrArray.push("/gremlin");
let joinedConnection = connectionStrArray.join("")
console.log(joinedConnection)
let dc = new DriverRemoteConnection(joinedConnection);
const g = traversal().withRemote(dc)
然后是一些await g.V().hasLabel 或类似的。
但我得到的只是:
Cannot read property 'processor' of undefined
使用 Graph (3.3.4) 的旧方式运行良好 https://github.com/apache/tinkerpop/blob/3.3.5/CHANGELOG.asciidoc#release-3-3-5
const graph = new Graph();
const g = graph.traversal().withRemote(dc);
我做错了什么? 我错过了什么?
更新
显然我需要添加 travelsource?
{ traversalSource: 'g' }
我找不到任何添加此内容的文档,并且仅被少量引用..
更新 2
对于懒人:这是我开始工作的代码
const gremlin = require('gremlin');
const traversal = gremlin.process.AnonymousTraversalSource.traversal;
const DriverRemoteConnection = gremlin.driver.DriverRemoteConnection;
const clusterEndpoint = process.env.CLUSTER_ENDPOINT;
const port = process.env.CLUSTER_PORT;
const connectionStrArray = [];
connectionStrArray.push("wss://");
connectionStrArray.push(clusterEndpoint);
connectionStrArray.push(":");
connectionStrArray.push(port.toString());
connectionStrArray.push("/gremlin");
const g = traversal().withRemote(new DriverRemoteConnection(connectionStrArray.join(""), { traversalSource: 'g' }));
【问题讨论】: