Let’s say I have an ordered list of items and order is defined by “position” attribute stored in the database.
- item a (position: 1)
- item b (position: 2)
- item c (position: 3)
- item d (position: 4)
Now I want to reorder the list and move item d to the top
- item d (position: 4 -> 1)
- item a (position: 1 -> 2)
- item b (position: 2 -> 3)
- item c (position: 3 -> 4)
The position of all elements has changed and I would have to do a separate PATCH for every element. I don’t want to do it this way because of several reasons:
- the list can be huge
- some items in the list can be hidden
What I’m actually searching for is another way of ordering items where reordering could be done only by PATCHing one resource.
Closest idea I have now is ordering by pointers (where one item points to another). When reordering in this way you have to only PATCH two resources. The problem here is how to order items in the database this way…