The logbook can be read; now it needs to be written to: an order taken in the app must go into the table, not just into memory.
Your mission
- In
Store, after the validation, insert the order into thelivraisonstable withfacades.DB(). - Respond 201 with the delivery, and the number the database gave it.
- An invalid order still responds 422, and writes nothing.
- The in-memory round, the
livraisonsslice, has no reason to exist anymore: remove it.
Reminder
InsertGetID(data) inserts a row and returns the number SQLite assigned to it, 6 here, since the logbook already holds 5. The data is a map[string]any, from columns to their values. For several rows at once, Insert takes a slice of maps.
Go never converts one numeric type into another unless you ask: an int64 doesn't fit into an int. int(id) does the conversion. It's one of the rules that surprise you coming from PHP, and that save you from many surprises later on.