Coder Social home page Coder Social logo

How Do I Remove Edge about arangolite HOT 5 OPEN

solher avatar solher commented on August 17, 2024
How Do I Remove Edge

from arangolite.

Comments (5)

solher avatar solher commented on August 17, 2024

To be honest, I also don't really understand why the ArangoDB team never implemented some kind of delete cascade.

The remove vertex operation from the graph management interface is Javascript so I would not consider it as a viable option in a Go program (but I did it with the transactions so why not...).
The Javascript API is still way ahead of AQL (for example the transactions that can only be done using Javascript right now) but they are working hard on implementing everything natively for AQL and ArangoDB 3.0 should be a great step towards that.

from arangolite.

didasy avatar didasy commented on August 17, 2024

Yea, it feels really incomplete right now when AQL doesn't have the same capability as the JS interface.

I think I should get the edge first somehow to get the key, then do a Send to DELETE /_api/edge/{col}/{key}.

Thought?

from arangolite.

solher avatar solher commented on August 17, 2024

Actually, the best solution I found for now is using the AQL traversals like that:

    t := arangolite.NewTransaction(
        nil,
        []string{"users","dashboards","dashboardRights","devices","deviceRights"},
     ).AddQuery("users", `
        FOR u IN users
        REMOVE u IN users
        RETURN u
    `).AddQuery("", `
        FOR u IN {{.users}}
            FOR v,e IN OUTBOUND u dashboardRights, deviceRights
            REMOVE v IN dashboards OPTIONS { ignoreErrors: true }
            REMOVE e IN dashboardRights OPTIONS { ignoreErrors: true }
            REMOVE v IN devices OPTIONS { ignoreErrors: true }
            REMOVE e IN deviceRights OPTIONS { ignoreErrors: true }
    `).Return("users")

The thing which is not cool is that we have to statically indicate the collection in which we want to remove a vertex/edge. So here we have basically to try every possibility. Still not very beautiful haha.

from arangolite.

didasy avatar didasy commented on August 17, 2024

Seems complicated for a task so simple.

I think I need to learn AQL more to totally understand what's going on in that query.

from arangolite.

solher avatar solher commented on August 17, 2024

Yeah I know and I totally agree with you. There should be some simple way to cascade when there's a deletion...

from arangolite.

Related Issues (17)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.