I'm having a series of data as documents in a document db (CouchDB)
Sample of a document looks like below
{
_id: xxx
_rev: xxx
data: xxx
position: 1
}
These documents displays in a web front-end in a vertically scrollable list and any item can be dragged and dropped to change position.
The position
key is always unique and programmatically using it to sort and manage the "drag and drop" feature.
In a drag and drop, dragged item's (document's) position
updates to the new position along with the all the other documents which got higher position
number than the dragged document's position.
As an example: in a 1000 item list, if 6th item dragged to 2nd place, all the 3 to 1000 documents should be updated with the new position
With the current system, we use couchDB update handler to update each document to it's new position.
With few thousand documents, its taking less time to update all the documents to newer position. However the number of docs can be few hundred thousand in future.
Is there a better way of handling a "drag n drop" other than recording and maintaining the position.