I have elements of a list in couchdb documents. Let's say these are 3 elements in 3 documents:
{ "id" : "783587346", "type" : "aList", "content" : "joey", "sort" : 100.0 }
{ "id" : "358734ff6", "type" : "aList", "content" : "jill", "sort" : 110.0 }
{ "id" : "abf587346", "type" : "aList", "content" : "jack", "sort" : 120.0 }
A view retrieves all "aList" documents and displays them sorted by "sort".
Now I want to move the elements, when I want to move "jack" to the middle, I could do this atomic in one write and change it's sort key to 105.0. The view now returns the documents in the new sort order.
After a lot of sorting I could end up with sort keys like 50.99999 and 50.99998 after some years and in extreme situations run out of digits?
What can you recommend, is there a better way to do this? I'd rather keep the elements in seperate documents. Different users might edit different list elements in parallel.
And users might also change the document order at the same time (which also can get tricky when 2 users want to move two different documents (like joey and jill) to the end with let's say "sort" = 130.0 at the same time).
Maybe there is a much better way?
Did I miss something on CouchDb transactions?