Update a MAP attribute in an edge within a query

Hello, we have a vertex Person and a directed edge TO and FROM Person with one attribute of type MAP<STRING, INT>

eg., person1 -(MAP[“07/2020” -> 10,“08/2020” -> 4])-> person2

We have query that inserts this type of data initially.

After initial load, is there a way to update the map value in the edge? We could also have instances where we may need to insert as well.

We have a query that calculates the changes to initial load and generates an accum that stores (FROM eg., person1, TO eg., person2, MAP eg., [“08/2020” -> 6, “09/2020” -> 1])

eg., If that query finds -

  1. Finds count for “08/2020” from person1 to person2 is changed to 6 now then it should update it to following,
    person1 -(MAP[“07/2020” -> 10,“08/2020” -> 6])-> person2

  2. Finds count for “09/2020” from person1 to person2 is changed to 3 now then it should update it to following,
    person1 -(MAP[“07/2020” -> 10,“08/2020” -> 6,“09/2020” -> 6])-> person2

  3. Finds that unconnected person3 and person4 now has a “09/2020”: 1 then it should insert the edge between person3 and person4 as following
    person3 -(MAP[“09/2020” -> 1])-> person4

Is there a way to achieve this scenario in a query?

Hello, I was able to achieve INSERT/ UPDATE requirement using 2 different queries. First query would generates an accum that stores (FROM eg., person1, TO eg., person2) and then iterate through that accum to INSERT the edge, if doesn’t exists. Followed by another query which would generate an accum that stores (FROM eg., person1, TO eg., person2, MAP eg., [“08/2020” -> 6, “09/2020” -> 1]) to perform UPDATE to the edge attribute.

Please let me know if there is any other or a better way of doing this :slight_smile: