javascript - 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));
解决方案
我认为你需要迭代你的 traversal。
g.V('19071640').inE('friend').count().next().then(num => console.log(num));
推荐阅读
- sql - 合计员工/plsql的总就业时间/年
- java - 为什么我必须为位掩码声明一个长变量?
- python - Heroku 30s 超时错误,如何使 Django 将变量创建视为后台任务(工作者)?
- java - 使用 setOnClickListener 将项目绑定到位置
- parsing - 为带括号的逻辑运算符实现上下文无关文法
- java - “变量”不能解析为变量
- c# - 检查字典字典中的内部字典是否包含值
- r - Extracting P-value column from output Anova (car package)
- python-3.x - 使用 Python 模块的 Internet 点击次数
- python - 为什么这个 SQL 查询会失败?