← Files Electrical Progress TrackerARCHIVED FILE

skills/create-tracker/assets/source/db/index.ts

423 Bytes · Oct 4, 2026 · 12:34 UTC

↓ Download file

import { env } from "cloudflare:workers";
import { drizzle } from "drizzle-orm/d1";
import * as schema from "./schema";

export function getDb() {
  if (!env.DB) {
    throw new Error(
      "Cloudflare D1 binding `DB` is unavailable. Set the `d1` field in .openai/hosting.json to `DB` or let your control plane inject the real binding values before using the database."
    );
  }

  return drizzle(env.DB, { schema });
}

SHA-256: dc7610b00b918e0ffff1360a63626f16655ced3064b2eaf96095a4101fb14bcd