dongwupu5991 2019-04-09 19:14
浏览 169
已采纳

AQL更新在收集循环中成功,但是在图形遍历中引发未找到的错误

I am trying to figure out how to update edge documents using a graph traversal query in arangodb. I am able to do this using the standard FOR e IN collectionName UPDATE e with {newProps} IN collectionName. However I cannot figure out what is wrong with my attempt to accomplish the same thing using the FOR v, e, p IN 1..5 OUTBOUND @startId GRAPH @graphName syntax.

I am using the arangodb:latest docker image on macOS Mojave 10.14.3, and I am using arango's go library (github.com/arangodb/go-driver) to query by building a query string and sending it using the Database.Query() function. I have tried just returning the key for the edge I'm trying to update (i.e. just returning e._key instead of attempting to update in the query below), and have verified using arangosh that that is indeed the correct key of the edge I'm trying to update. Additionally as stated above, I have been able to update an edge using the relational AQL syntax.

Here is my query:

FOR v, e, p IN 1..5 OUTBOUND @startId GRAPH @graphName
    FILTER e.@key0 == @val0
    UPDATE e._key WITH {@propName0: @propValue0} IN has_skill
    RETURN {new: NEW, old: OLD}

and here are my bind variables:

[graphName:Matthew_Loughney, key0:_from, propName0:testProp, propValue0:testVal, startId:applicant/232, val0:applicant/232]

I would expect that when I view the has_skill collection using arangosh, I would see that my edge now has a property testProp with value testVal; however, I instead just get the error AQL: document not found (while executing) and my edge remains unchanged.

  • 写回答

1条回答 默认 最新

  • douou6696 2019-04-09 20:19
    关注

    It turned out that my filter was returning some edges not in the has_skill collection (4 total to be exact), so when it tried to update in has_skill, it succeeded for the one I wanted but failed for the other 3, and since the UPDATE operation is atomic that made it fail for all of them. I did not notice this because I was only looking at the first edge returned when looking at the keys, and this wasn't an issue in my FOR e IN collectionName query because obviously those are all in the correct collection, so that only returned the 1 edge I was looking for.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 drone 推送镜像时候 purge: true 推送完毕后没有删除对应的镜像,手动拷贝到服务器执行结果正确在样才能让指令自动执行成功删除对应镜像,如何解决?
  • ¥15 求daily translation(DT)偏差订正方法的代码
  • ¥15 js调用html页面需要隐藏某个按钮
  • ¥15 ads仿真结果在圆图上是怎么读数的
  • ¥20 Cotex M3的调试和程序执行方式是什么样的?
  • ¥20 java项目连接sqlserver时报ssl相关错误
  • ¥15 一道python难题3
  • ¥15 牛顿斯科特系数表表示
  • ¥15 arduino 步进电机
  • ¥20 程序进入HardFault_Handler