我正在寻找能够创建完整TinkerGraph图的GraphSON序列化的单个查询。
// setup
const gremlin = require('gremlin')
const connection = new gremlin.driver.DriverRemoteConnection('ws://localhost:8182/gremlin')
const g = (new gremlin.structure.Graph()).traversal().withRemote(connection)我可以将顶点、边和属性分别序列化为GraphSON。以下语句仅创建所有顶点的GraphSON序列化。可以用E()查询边,用V().properties()查询属性。
// placed within an async function
const writer = new gremlin.structure.io.GraphSONWriter()
const serialisedVertices = writer.write(await g.V().toList())有没有一个gremlin-javascript方法可以在一个步骤中将所有的顶点、边和属性一起(而不是像上面那样单独地)序列化为一个GraphSON字符串?
另外,如果一个完整的图可以被序列化为单个GraphSON字符串,那么是否还有一个匹配的调用将从GraphSON字符串中重新生成一个图实例?
发布于 2019-09-01 04:59:46
从gremlin 3.4.x开始,您可以使用io步骤:
g.io("graph.json").read().iterate()
g.io("graph.json").write().iterate()这些命令以graphson格式读取/写入完整的图形数据,这是一个json文件。在tinkerpop documentation中编写了更多受支持的格式
如果您运行的是gremlin 3.3.x,则可以使用following command
graph.io(graphson()).writeGraph("graph.json");请注意,该文件存储在gremlin服务器的当前工作目录中。
https://stackoverflow.com/questions/57738272
复制相似问题