我想仅从_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
答案 0 :(得分:1)
您可以收集p.path
和vertices
子属性的ID,而不是返回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/..."
]
}
]