0

_id下からエッジと頂点のみを返したいp.path

LET from = (
    FOR u IN products
        FILTER u.name == 'pagfr21'
        RETURN u._id
)
FOR p IN TRAVERSAL(products, productsrelated, from[0], 'outbound',
        {minDepth: 0, maxDepth: 3, paths: true})
    RETURN p.path
4

1 に答える 1

1

返す代わりに、とサブ属性p.pathの ID を収集し、それらを 2 つの別々の配列で返すことができます。verticesedges

LET from = (FOR u IN products FILTER u.name == 'foo' RETURN u._id) 

FOR p IN TRAVERSAL(products, productsrelated, from[0], 'outbound', {
  minDepth: 0, 
  maxDepth: 3, 
  paths: true 
}) 

RETURN { 
  vertices: p.path.vertices[*]._id, 
  edges: p.path.edges[*]._id 
}

次のような構造を返します。

[
  {
    "vertices": [
      "products/..."
    ],
    "edges": []
  },
  {
    "vertices": [
      "products/...",
      "products/..."
    ],
    "edges": [
      "productsrelated/..."
    ]
  },
  ...
  {
    "vertices": [
      "products/...",
      "products/...",
      "products/..."
    ],
    "edges": [
      "productsrelated/...",
      "productsrelated/..."
    ]
  }
]
于 2015-08-25T16:13:27.963 に答える