我有一个 Gremlin API Cosmos DB。在数据库中,我有一种 Vertice with LabelUser
连接到 Vertices 标签Companies
。然后我想展示所有关联的公司。我进行查询g.V('id-of-User').outE()
并获取所有连接的公司。结果可能如下所示:
[
{
"id": "08f97a1d-9e81-4ccc-a498-90eb502b1879",
"label": "AuthorizedSignatory",
"type": "edge",
"inVLabel": "Company",
"outVLabel": "User",
"inV": "abd51134-1524-44fe-8a49-60d2d449a1f3",
"outV": "103bf1b9-464f-4f68-a4ca-7dfdbe94ae84"
},
{
"id": "c36b640b-9574-403b-8ab6-fcce695caa90",
"label": "AuthorizedSignatory",
"type": "edge",
"inVLabel": "Company",
"outVLabel": "User",
"inV": "2c14d279-00a4-41ad-a8c0-f3b882864568",
"outV": "103bf1b9-464f-4f68-a4ca-7dfdbe94ae84"
}
]
这完全符合预期。现在我想更进一步,而不是只在 inV 参数中显示 GUID,我还想在结果对象中包含公司名称,但我不明白如何在此处执行与 SQL 连接等效的操作。
有人可以帮帮我吗!!
我想要的是类似于下面的例子:
[
{
"id": "08f97a1d-9e81-4ccc-a498-90eb502b1879",
"label": "AuthorizedSignatory",
"type": "edge",
"inVLabel": "Company",
"outVLabel": "User",
"inV": "abd51134-1524-44fe-8a49-60d2d449a1f3",
"outV": "103bf1b9-464f-4f68-a4ca-7dfdbe94ae84",
"CompanyName": "ACME CORP"
},
{
"id": "c36b640b-9574-403b-8ab6-fcce695caa90",
"label": "AuthorizedSignatory",
"type": "edge",
"inVLabel": "Company",
"outVLabel": "User",
"inV": "2c14d279-00a4-41ad-a8c0-f3b882864568",
"outV": "103bf1b9-464f-4f68-a4ca-7dfdbe94ae84",
"CompanyName": "Giganticorp"
}
]
其中CompanyName
是 Company Vertice 中的属性之一,其中的 guid 位于inV
prop 中。