Skip to the content

Capsid menu

app/db/settings.ts

18 lines and 2 functions in DrDustinEdwards/dustinedwards-info, at commit 1590ba4 on 2026-10-24. This file on GitHub.

Functions

The functions of settings.ts
FunctionLinesComplexityCoveredCRAPMutation
getSetting6 to 132No data: no coverage report in this mapNo data: no coverage report in this mapNo data: no mutants in this code
setSetting15 to 201No data: no coverage report in this mapNo data: no coverage report in this mapNo data: no mutants in this code

Imports

It imports app/db/client.ts, app/db/schema.ts. Imported by app/db/index.ts, app/lib/llms/save.server.ts.

Source

// The key-value settings table.
import { eq } from "drizzle-orm";
import { settings } from "./schema";
import { getDb } from "./client";

export async function getSetting(env: Env, key: string) {
  const rows = await getDb(env)
    .select({ value: settings.value })
    .from(settings)
    .where(eq(settings.key, key))
    .limit(1);
  return rows[0]?.value ?? null;
}

export async function setSetting(env: Env, key: string, value: string) {
  await getDb(env)
    .insert(settings)
    .values({ key, value })
    .onConflictDoUpdate({ target: settings.key, set: { value } });
}