Skip to content

Commit

Permalink
feat: add user to D1 sample endpoint
Browse files Browse the repository at this point in the history
  • Loading branch information
kimitrii committed Nov 22, 2024
1 parent 850d51e commit bf5f41a
Showing 1 changed file with 14 additions and 3 deletions.
17 changes: 14 additions & 3 deletions src/index.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,20 @@
import { Hono } from 'hono'
import { drizzle } from 'drizzle-orm/d1';
import { Env } from './types/drizzleTypes';
import { users } from './db/schema';

const app = new Hono()
const app = new Hono<{ Bindings: Env}>()

app.get('/', (c) => {
return c.text('Hello Hono!')
app.get('/', async (c) => {
const db = drizzle(c.env.DB)

await db.insert(users).values({
name: 'Eric',
})

const dbUsers = await db.select().from(users)

return c.json(dbUsers[0])
})

export default app

0 comments on commit bf5f41a

Please sign in to comment.