Files
HiveGrid-Wireframes/03 Quellen und Referenzen/hivegrid-cloud/apps/web/app/utils/db.server.ts
T
2026-07-08 16:15:37 +02:00

18 lines
645 B
TypeScript

import { getDbClient, getReadDbClient } from "@hivegrid/db/client.server";
const db = getDbClient();
/**
* Read-replica accessor for hot-read paths (CRM/KB listings, dashboards,
* public sites/portals, analytics aggregations). Falls back to the write
* singleton when `DATABASE_READ_URL` is unset, so single-DB dev / self-
* hosted setups keep working unchanged. Do NOT use right after a write
* inside the same request — replication is eventually consistent.
*
* See `docs/architecture/rw-split.md` for the convention table and the
* read-after-write hazard discussion.
*/
const dbRead = getReadDbClient();
export { db, dbRead };