Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

I have the same problem right now.

I use an unsigned int "pos" column in the db.

For a new list the "pos" starts with 1..n

When the user changes the order I find the largest "pos" in the list and with a for I set largest + n "pos" for every item.

There will be about 20 items in a list but let's just assume it's a 1000, so with this I'm good if the user edits the list less than 4 294 967 295 / 1000 times.

And if the largest + count(list) < lowest I can set the largest to zero and start over the pos with 1.



Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: