Files
WRNexusJS/examples/basic-app/app/db/queries.gen.ts
T
ClintchizandClaude Opus 5 b3b65dddd8
Quality / quality (ubuntu-latest) (push) Failing after 12m46s
Quality / quality (windows-latest) (push) Canceled after 0s
fix(db): stamp the dialect into generated query files
The same generate command emitted ? one run and $1 the next, which looked
like non-determinism. It is not: postgres uses $1 placeholders where
sqlite and mysql use ?, and the driver comes from the active profile, so
building under a different profile rewrites this committed file.

The header now records the dialect it was generated for, making the flip
visible in the diff and explaining check:generated-types failures instead
of leaving them looking like random churn.

Worth deciding separately: a committed artifact whose contents depend on
the active profile will keep drifting. Either generate per dialect, or
stop committing it.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
2026-08-18 19:44:36 +05:30

24 lines
1.4 KiB
TypeScript

// AUTO-GENERATED by `wrnexus db generate` (dialect: sqlite) — do not edit.
import type { Db, ExecResult } from "@wrnexus/db";
import { users } from "./schema.ts";
export async function GetUserByEmail(db: Db, args: { email: string }): Promise<{ id: number; email: string; name: string; active: boolean; passwordHash: string; createdAt: Date } | null> {
return (await db.one("SELECT * FROM users WHERE email = ?", [args.email], users)) as { id: number; email: string; name: string; active: boolean; passwordHash: string; createdAt: Date } | null;
}
export async function ListUsers(db: Db): Promise<{ id: number; name: string; active: boolean }[]> {
return (await db.all("SELECT id, name, active FROM users ORDER BY name", [], users)) as { id: number; name: string; active: boolean }[];
}
export async function CountActive(db: Db, args: { active: boolean }): Promise<{ n: number } | null> {
return (await db.one("SELECT COUNT(*) AS n FROM users WHERE active = ?", [args.active])) as { n: number } | null;
}
export async function CreateUser(db: Db, args: { email: string; name: string; active: boolean }): Promise<ExecResult> {
return db.exec("INSERT INTO users (email, name, active) VALUES (?, ?, ?)", [args.email, args.name, args.active]);
}
export async function DeactivateUser(db: Db, args: { id: number }): Promise<ExecResult> {
return db.exec("UPDATE users SET active = 0 WHERE id = ?", [args.id]);
}