Gremlin, javascript: where is the function “valueMap()” imported from?

扶醉桌前 提交于 2020-12-26 07:35:01

问题


I am using es6 on nodejs, and am trying to execute the project() step in a gremlin query.

As part of the projection, I want to extract the properties.

Using gremlin console I would use valueMap() to get the properties.

However, when I attempt this from javascript, I get the expected error "valueMap is not a function".

Question 1: where do I import this function from?

Question 2: where can I read about all of the various gremlin objects available for importing in javascript?

===========================

I am using Gremlin 3.3 connecting to an AWS Neptune instance.

Here is my gremlin code:

g.V('test-id')  
    .bothE()  
    .limit(10)  
    .project('id', 'properties', 'out', 'in')  
    .by(id)  
    .by(valueMap())  
    .by(outV().id())  
    .by(inV().id())  

回答1:


valueMap(), outV() and similar traversals are spawned anonymously from a double underscore class - __ - so your code could be re-written as:

const gremlin = require('gremlin');
const __ = gremlin.process.statics;

g.V('test-id')  
    .bothE()  
    .limit(10)  
    .project('id', 'properties', 'out', 'in')  
    .by(id)  
    .by(__.valueMap())  
    .by(__.outV().id())  
    .by(__.inV().id()) 


来源:https://stackoverflow.com/questions/52780615/gremlin-javascript-where-is-the-function-valuemap-imported-from

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!