literallypenguin
literallypenguin

Reputation: 121

Arange AQL Remve Document and Edges

Back with another arango question.

Is there a simple way to remove a document and all of its edges? Is this solution recursive?

Again lets say I have something like the below.

Then I have two Edge Collections HAS_CIRCLE and HAS_SQUARE which correspond appropriately to the various \ indicated.

   Circle A
    /       \
 Square 1    Circle B 
            /     \         \
       Circle C   Square 2  Square 3
       /
     Square 4

If I want to delete Circle B. Then I also wanted to delete Circle C, Square 2, Square 3, and Square 4. Along with all the edges.

So basically I would end up with.

   Circle A
    /     
 Square 1  

Right now my approach is to get all the keys for Circle C's edges and associated documents. Then I do this recursively with javascript. I'm using the arangojs module and using the removeByKeys once I have what I need.

Unsure if there was some magic I'm missing.

Upvotes: 2

Views: 89

Answers (1)

dothebart
dothebart

Reputation: 6067

It works the way that you have to first find out all the IDs of the documents you want to delete and keep it conjunction with the collection they're in.

Once you've collected all IDs, you need to issue one REMOVE statement for each collection with a list of the IDs.

You can find example AQL queries how to achieve this in the very similar question Safe removal of vertexes in ArangoDB (using _ids)? .

Upvotes: 1

Related Questions