简体   繁体   English

使用arangodb AQB,您如何从/到/从Edge进出? 在查询中?

[英]With arangodb AQB how do you get out/inEdges an from/toVertices? in a query?

Suppose the following query from fluent query interface thats removed as of v3.x : 假设从v3.x删除的fluent query interface的以下查询:

var tens = graph._vertices(lst).outEdges().restrict("knows").toVertices()
.inEdges().restrict("works").fromVertices().inEdges().restrict("owns")
.fromVertices().toArray();

here lst is a simply a list of vertices obtained from a prior query, and the vertices in lst may have outgoing edge relationships one of which is of type knows , and the vertices pointed to by these outEdges have incoming edges of type works in turn, 这里lst是从先前的查询获得的顶点的简单列表,并且在顶点lst可以具有外向边缘的关系其中之一是的类型knows ,和顶点由这些outEdges指出有类型的入边works反过来

how would this be written with AQB? 如何用AQB编写? the two (AQB and fluent query interface are supposed to overlap and thats why one was removed). 两者(AQB和fluent query interface应该重叠,这就是为什么要删除其中一个)。 Iv looked at the documentation on github but im not seeing anything that would help with a query like the one above iv查看了github上的文档但是我看不到任何有助于上述查询的内容

This is what i have worked out so far: 到目前为止,这是我解决的问题:

db._query("FOR vrt0 in @lst FOR vrt1  in OUTBOUND vrt0 knows FOR vrt2 in 
INBOUND vrt1 works  FOR vrt3 in INBOUND vrt2 owns RETURN vtr3",{"@lst": lst });

The information retrieved is equivalent to what i would expect from the corresponding fluent query interface . 检索到的信息等效于我期望从相应的fluent query interface

You're correct that this can't be represented in AQB. 您是正确的,它不能在AQB中表示。 We're currently in the process of deprecating AQB in favour of the aql template handler supported by both the JavaScript driver (arangojs) and ArangoDB 2.8 and later: https://docs.arangodb.com/3/Manual/Appendix/JavaScriptModules/ArangoDB.html#the-aql-template-string-handler 我们目前正在弃用aql ,以支持JavaScript驱动程序(arangojs)和ArangoDB 2.8及更高版本均支持的aql模板处理程序: https ://docs.arangodb.com/3/Manual/Appendix/JavaScriptModules/ ArangoDB.html#the-aql-template-string-handler

With the template string handler it is possible to write arbitrary AQL queries in ArangoDB 3. If I understand it correctly, your fluent query should translate to something like this: 使用模板字符串处理程序,可以在ArangoDB 3中编写任意AQL查询。如果我对它的理解正确,那么您的流利查询应转换为以下形式:

db._query(aql`
  FOR vertex IN ${lst}
  FOR v1 IN OUTBOUND vertex knows
  FOR v2 IN INBOUND v1 works
  FOR v3 IN INBOUND v2 owns
  RETURN v3
`).toArray()

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM