我正在 Lambda 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 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);
我究竟做错了什么?
我错过了什么?
UPDATE
显然我需要添加travelsource?
{ traversalSource: 'g' }
我找不到任何添加此内容的文档,并且仅很少引用它。
Update 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' }));
同样的错误也发生在我身上:
TypeError: Cannot read property 'processor' of undefined
traversalSource不是必须的,具体解决方案是给DriverRemoteConnection的第二个参数传递一个空对象:
const g = traversal().withRemote(new DriverRemoteConnection(process.env.DATABASE_URL_LOCAL, {}));
所以问题似乎是 gremlin 客户端中缺少内部空检查。
当我更新 gremlin 服务器时,这种情况开始发生,我没有在客户端上更改任何内容,奇怪......
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)