Files
HiveGrid-Wireframes/hivegrid-cloud/apps/web/app/utils/db.server.ts
T

18 lines
645 B
TypeScript

import { getDbClient, getReadDbClient } from "@toolctrl/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 };