Search code examples
arangodbaql

How to add/remove attributes in a document before returning it in ArangoDB?


I am trying to query a document. Before I return the document, I need to delete some attributes like _id, _rev and add a few other calculated attributes. How can I achieve this?


Solution

  • To remove some attributes you can use the UNSET functions:

    FOR item in collection
        RETURN UNSET(item, "_id", "_key", "_rev")
    

    Regarding calculating new attributes it mostly depends on what you want to achieve but there are a lot of available functions in AQL. If you give us a bit more details we could find what works for you!

    Sources: