Can transaction.on_commit() be used to

20 views Asked by At

I have a function that delete an object from a group of objects bound together and that are ordered by a "order" value they have like this:

`{id:23, name:name1, order:1}
 {id:12, name:name2, order:2}
 {id:46, name:name3, order:3}`

After deleting other objects order should change to represent the deletion, like if i delete the object with id 12 the object with id 46 should become "order:2"

This i can make easy with a function that get the others objects and lowers every object with more than order 2 by one but if i update those objects sometimes happens that they are reordered in the database before the delete has ended.

So, can i use transaction.on_commit() so the reorder function does not execute after the delete has ended? Or there is something i am missing?

Trying it does not appear to be a problem, but i don“t now if i am not doing anything to resolve my problem or i am misreading something of the correct usage of this function

0

There are 0 answers