Current implementation is really badly implemented as it is based on code which assumes transactions. For MongoEngine (and MongoDB) this is of course not true, so some improvements to operations should be done to implement them through atomic operations. And not through current fetch-update-save cycle.
Even worse is for subresources (lists), especially because we use indexes so things could move around and something would not be anymore on its place. You want to delete n-th element, but that element could be already something else at the time it is processed. Maybe we should introduce some dummy UUID/PKs to make sure we know what we are operating on. Operations on subresources should be really implemented through MongoEngine/MongoDB atomic operations on list and not changing list in the code.
Current implementation is really badly implemented as it is based on code which assumes transactions. For MongoEngine (and MongoDB) this is of course not true, so some improvements to operations should be done to implement them through atomic operations. And not through current fetch-update-save cycle.
Even worse is for subresources (lists), especially because we use indexes so things could move around and something would not be anymore on its place. You want to delete n-th element, but that element could be already something else at the time it is processed. Maybe we should introduce some dummy UUID/PKs to make sure we know what we are operating on. Operations on subresources should be really implemented through MongoEngine/MongoDB atomic operations on list and not changing list in the code.