d1-starter-sessions-api-template
cloudflare/templates
Official starter for a session API on D1. Sessions are a row-read and row-write workload, which is the meter people undercount when they only think about requests.
Index the session lookup. A session table scanned on every request is how a small API spends the 5 million daily Free reads.
Products: Workers and D1.
Open a worked model of this shape in the calculator
https://github.com/cloudflare/templates/tree/main/d1-starter-sessions-api-template