Ziex DB Example

Cloudflare D1 dashboard with query code separated into query.zig

This page creates tables, seeds a few records, and renders aggregate metrics from a single query. The page handles orchestration and UI, while the SQL lives beside it in a small query module.

Customers

3

Unique customer rows in the demo dataset.

Orders

3

All inserted orders, regardless of status.

Paid Orders

2

Subset filtered directly in SQL.

Revenue

$76.+0

Summed from amount_cents.

What This Route Demonstrates

It is meant to show a practical structure for DB-powered pages: keep the SQL in a local helper module, expose small query functions, and let the page focus on composing the result into UI.

  • Initializes customers and orders tables.
  • Seeds a compact dashboard dataset.
  • Uses one aggregate query to load all summary metrics.
  • Formats the returned values into a simple admin-like view.

Latest Snapshot

The query also asks for the latest order timestamp so the page can display one more real field coming back from D1.

latest_order_at: 2026-04-19 05:06:55