There is some form in a web form. It contains the list of items that use can edit, remove and change.
When the server receive the list of items, it should update existing items, create ones and remove the deleted ones.
I only know the naive and quite ugly approach:
-
When server receives the list of items from a client, it gets the actual list of items from the database
-
Pass round the received list of items:
2.1. If element has the ID and database has the element with this ID, this element updates
2.2. If this element doesn't have ID or database doesn't contain element with this ID, this element creates
-
Delete all items, that were not in the received list (marked as deleted)
-
The updated list of items are returnded to the client (with new IDs), and client displays them
I feel, that there is more elegant solution, and, propably, established for this task.
Aucun commentaire:
Enregistrer un commentaire