在 AQL 中如何重新设置顶点的父级
In AQL how to re-parent a vertex
我正在尝试重新设置顶点的父级。这个我试过了,好像没效果
FOR c IN pm_child FILTER c._to == 'pmlibrary/48198494363' UPDATE c WITH {_from: 'pmattic/48212650139'} IN pm_child
当我查看 pm_child 集合时,_from 字段未受影响。修改边的正确方法是什么?
作为 _key
-属性 _from
和 _to
are system attributes and thus immutable.
因此,虽然您可以在创建文档时指定它们,但以后不能更改它们。
您需要使用新的 _from
和 _to
创建一个新文档才能实现您想要的效果。
We're thinking about how queries could raise a warning但还没有找到好的解决方案。
我会给你一个例子如何做到这一点 using the social graph - Lets make bob a friend of charly and disconnect bob and diana. We need to create a new document were we MERGE
现有的边和它的新边 _to
:
FOR rel IN relation FILTER rel._id == "relation/bobAndDiana"
LET newRel = MERGE(rel, {_to: "persons/charlie",
_id:"relation/bobAndCharlie",
fieldToWhipe: null,
_key: "bobAndCharlie"})
INSERT newRel IN relation RETURN newRel
并在另一个查询中删除原来的边(你可能想为此写一个事务):
FOR rel IN relation FILTER rel._id == "relation/bobAndDiana" REMOVE rel IN relation
随着 ArangoDB 3.0 版本的发布,直接更新 _from
和 _to
成为可能。
我正在尝试重新设置顶点的父级。这个我试过了,好像没效果
FOR c IN pm_child FILTER c._to == 'pmlibrary/48198494363' UPDATE c WITH {_from: 'pmattic/48212650139'} IN pm_child
当我查看 pm_child 集合时,_from 字段未受影响。修改边的正确方法是什么?
作为 _key
-属性 _from
和 _to
are system attributes and thus immutable.
因此,虽然您可以在创建文档时指定它们,但以后不能更改它们。
您需要使用新的 _from
和 _to
创建一个新文档才能实现您想要的效果。
We're thinking about how queries could raise a warning但还没有找到好的解决方案。
我会给你一个例子如何做到这一点 using the social graph - Lets make bob a friend of charly and disconnect bob and diana. We need to create a new document were we MERGE
现有的边和它的新边 _to
:
FOR rel IN relation FILTER rel._id == "relation/bobAndDiana"
LET newRel = MERGE(rel, {_to: "persons/charlie",
_id:"relation/bobAndCharlie",
fieldToWhipe: null,
_key: "bobAndCharlie"})
INSERT newRel IN relation RETURN newRel
并在另一个查询中删除原来的边(你可能想为此写一个事务):
FOR rel IN relation FILTER rel._id == "relation/bobAndDiana" REMOVE rel IN relation
随着 ArangoDB 3.0 版本的发布,直接更新 _from
和 _to
成为可能。