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

I agree, but I use a small improvement to the first approach: split each insert into two steps: "insert at end" and "reorder". That way: (a) the insert is nice and simple and (b) you can reuse the code for re-order which you likely need anyway (and which solves the foreign key constraint issue, perhaps by doing it in a single SQL update).


That was my first thought. Disallow inserting into the middle of the list and solution 1 becomes much simpler.




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

Search: