import { drizzle, type NodePgDatabase } from "drizzle-orm/node-postgres"; import type { Pool } from "pg"; import { deviceSchema } from "./schema.js"; export type DeviceDrizzleDatabase = NodePgDatabase; /** * A typed Drizzle view over an externally owned pool, exactly like `createAuthorizationDrizzleView`. * * There is deliberately no pool-constructing counterpart: device identity is only ever read and * written by the running API, which already owns one validated pool. A second constructor would be * a second place for transport policy to drift. */ export function createDeviceDrizzleView(pool: Pool): DeviceDrizzleDatabase { return drizzle(pool, { schema: deviceSchema }); }