Need last location after moving node in diagram

I want to capture updated location and want to save it to the database. I checked that once move transaction is committed it gives multiple locations. for example if i start moving 1 node and drop it somewhere, it give me 10 change events. I just want to store final location from data.location property along with the key of node.

If i move a group, i want final location of every node along with key. Also group key and its location.

how can i do this ?

You can get the final locations after the transaction has finished. So the only time you should be saving to a database is in a Model Changed event when the transaction has finished.

https://gojs.net/latest/intro/changedEvents.html#SavingModelWhenTransactionsComplete

I am currently doing same way. Still it has change list of multiple location after transaction is committed.

I have produced same using following demo.

I moved a node slightly only, still it generated lots of move events.

pls suggest.

Well, of course there are going to be a lot of ChangedEvents during a drag, because during a real-time drag there will be a lot of changes to the location of each moved node.

My point is that if you save information to a database at the time of the end of the transaction, each moved node will only have one location, the final one.

So, you mean to say that even if we use e.isTransactionFinished, we will get multiple ChangeEvents for single node move.

Current code for getting location is as per following. It also prints multiple locations for single move.

 if (e.isTransactionFinished) {
       if (tx instanceof go.Transaction) {
                    tx.changes.each(function (c) {
                           if (c.change === go.ChangedEvent.Property) {
                                   if(c.propertyName === "Location") {
                                            console.log(c.object.Location);
                                   }
                           }
                    }

}

can you please help me to modify this using which i can get final location after the move is complete?
For e.g i select 1 node and move it, it should give me key of the node and final location.
If i select 2 nodes and move it, i should get 2 records (both keys and their final Locations)

if i move a group, same should happen.

I want to save final location to database actually.

if this event fire 15 times, i dont want to make 15 calls to database with some intermediate data. I want to make only 1 database call with final location.

if (!e.isTransactionFinished) return;
var txn = e.object;
var nodes = new go.Map();
txn.changes.each(function(c) {
  if (c.change === go.ChangedEvent.Property && c.propertyName === "Location") {
      nodes.add(c.object.key, c.object.Location);
  }
});
nodes.each(function(kvp) {
  console.log("moved " + kvp.key + " to " + kvp.value.toString());
});