Skip to content

Commit 6ca0957

Browse files
dmealingclaude
andcommitted
docs: fix FR2 final-review nits (D1 dialect, README stale claim, Hono Context import)
- recipe: drop `dialect: "d1"` from the custom Generator example — codegen-ts only knows `"sqlite" | "postgres"`. D1 consumers use `dialect: "sqlite"` for codegen (D1 is SQLite at the SQL level) and `--dialect d1` for `meta migrate`. Adjacent note clarifies. - README: drop "with prepared statements" from the queries description — no longer accurate after the FR2 followup that simplified findXxxById to plain `db.select()...where(eq).limit(1)`. - recipe: replace `Hono.Context<Env>` with `Context<Env>` + named import from "hono". The namespace-style usage doesn't typecheck under Hono v4. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
1 parent 70fd2dd commit 6ca0957

2 files changed

Lines changed: 9 additions & 4 deletions

File tree

docs/recipes/wiring-generated-queries.md

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ Hono is the de facto edge HTTP router in 2026. Generated queries compose with
8989
it directly — no metaobjects-specific Hono integration needed.
9090

9191
```ts
92-
import { Hono } from "hono";
92+
import { Hono, type Context } from "hono";
9393
import { drizzle } from "drizzle-orm/d1";
9494
import {
9595
findUserById,
@@ -103,7 +103,7 @@ type Env = { Bindings: { DB: D1Database } };
103103

104104
const users = new Hono<Env>();
105105

106-
const getDb = (c: Hono.Context<Env>) => drizzle(c.env.DB);
106+
const getDb = (c: Context<Env>) => drizzle(c.env.DB);
107107

108108
users.get("/:id", async (c) => {
109109
const user = await findUserById(getDb(c), c.req.param("id"));
@@ -272,12 +272,17 @@ import { honoRoutesFile } from "./metaobjects-routes-hono";
272272

273273
export default defineConfig({
274274
outDir: "src/generated",
275-
dialect: "d1",
275+
dialect: "sqlite",
276276
apiPrefix: "/api",
277277
generators: [entityFile(), queriesFile(), honoRoutesFile(), barrel()],
278278
});
279279
```
280280

281+
> **Note for D1 consumers:** codegen-ts only knows `"sqlite" | "postgres"`. D1 is
282+
> SQLite at the SQL level, so codegen uses `dialect: "sqlite"`. The D1-specific
283+
> `--dialect d1` is a `meta migrate` CLI flag (it controls migration transport +
284+
> file layout), not a codegen config value.
285+
281286
## Migration from 0.6.0
282287

283288
```bash

server/typescript/packages/codegen-ts/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ Per entity, codegen emits **two files**:
3636

3737
- `<Entity>.ts` — Drizzle table definition (with FK `.references()` + `relations()` blocks
3838
auto-emitted from metadata relationships) + Drizzle-inferred types + Zod validators
39-
- `<Entity>.queries.ts` — typed CRUD query functions with prepared statements
39+
- `<Entity>.queries.ts` — typed CRUD query functions
4040
(`findPostById`, `listPosts`, `createPost`, `updatePost`, `deletePostById`)
4141

4242
Plus a barrel `index.ts` re-exporting from each `<Entity>.ts`.

0 commit comments

Comments
 (0)