0

I want to return only the _id from edges and vertices from the p.path below.

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您可以收集和子属性的 idvertices并将edges它们返回到两个单独的数组中,而不是返回,例如

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 回答