Part 16 / Topic 5 of 6
The write side: addEntry plus updateTag, and a real restart
// harness/app/mandi/guestbook/actions.ts (excerpt)
"use server";
export async function postGuestbookEntry(formData: FormData) {
// ...validate...
addEntry(name, message);
updateTag("mandi-guestbook");
}
Because the read side is cached (section 4), the write side needs Part 12 section 6's read-your-own-writes mechanism (updateTag), not Part 11's revalidatePath — there's a real cacheTag here for updateTag to target, unlike /mandi/top-categories's path-only revalidation. Run for real against this harness, across an actual, full server restart — not a simulated one:
$ npm run build && npm run start -p 3450
$ curl -s http://localhost:3450/mandi/guestbook -o page.html # read the real hidden $ACTION_ID_... field
$ curl -s -X POST http://localhost:3450/mandi/guestbook -F '$ACTION_ID_...=' -F 'name=Ravi' -F 'message=Great mangoes today, thanks!'
$ curl -s http://localhost:3450/api/mandi/guestbook
{"entries":[{"id":1,"name":"Ravi","message":"Great mangoes today, thanks!","createdAt":"2026-12-01T12:36:48.983Z"}]}
$ kill %1 # the server process, fully stopped
$ npm run start -p 3451 # a brand-new process, same .sqlite file on disk
$ curl -s http://localhost:3451/api/mandi/guestbook
{"entries":[{"id":1,"name":"Ravi","message":"Great mangoes today, thanks!","createdAt":"2026-12-01T12:36:48.983Z"}]}
Same id, same createdAt timestamp, from a server process that did not exist when the entry was written. This is the entire point of a real database over the in-memory arrays every earlier part used (Parts 9–15's lib/*.ts modules all reset on every restart) — and it is the exact guarantee the QuickCart capstone's own acceptance checklist requires for cart/order data.
Done here? The practice set for Part 16 — including the solutions — is on the part page.