首页 > 解决方案 > Gremlin 在 javascript AWS Lambda 中获得计数

问题描述

我正在尝试通过 AWS lambda 获取图表的边数,但出现错误

g.V(...).inE(...).outV(...).count(...).then is not a function

我的 lambda 代码是:

const gremlin = require('gremlin');
const DriverRemoteConnection = gremlin.driver.DriverRemoteConnection;
const Graph = gremlin.structure.Graph;

exports.handler = (event, context, callback) => {    
    let dc = new DriverRemoteConnection('ws://<endpoint>:8182/gremlin');

    const graph = new Graph();
    const g = graph.traversal().withRemote(dc);

    g.V('19071640').inE('friend').count().then(num => console.log(num));
}

如果我这样做,它会起作用

g.V('19071640').inE('friend').outV().then(friends => console.log(friends));

标签: javascriptamazon-web-servicesgremlin

解决方案


我认为你需要迭代你的 traversal

g.V('19071640').inE('friend').count().next().then(num => console.log(num));

推荐阅读