findAll caps at 2,000 rows, so aggregating in JavaScript silently undercounts on large tables. Push the math into the database instead: call zite.sql() from a backend workflow.
The pattern
One query per stat, returning typed results the frontend renders:recharts and the generated caller:
Rules
For the fullzite.sql() rules (SDK-name quoting, link-table joins), see the database client. Two that bite most on dashboards:
- Double-quote every identifier:
FROM "Orders", notFROM Orders. - Join linked records through the link table (
"ItemsOrders"with"itemsId"/"ordersId"), never on the JSONB field.