Skip to content

Commit 9d6f699

Browse files
committed
chore(playground): various fixes
1 parent 4a5b638 commit 9d6f699

File tree

8 files changed

+8
-7
lines changed

8 files changed

+8
-7
lines changed

playground/server/api/db-test.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { sqliteTable, integer, text } from 'drizzle-orm/sqlite-core'
22

33
export default defineEventHandler(async () => {
4-
const db = useDB()
4+
const db = useDrizzle()
55

66
const tables = await db.all(sql`
77
SELECT

playground/server/api/todos/[id].delete.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ export default eventHandler(async (event) => {
66
}).parse)
77

88
// List todos for the current user
9-
const deletedTodo = await useDB().delete(tables.todos).where(and(
9+
const deletedTodo = await useDrizzle().delete(tables.todos).where(and(
1010
eq(tables.todos.id, Number(id))
1111
)).returning().get()
1212

playground/server/api/todos/[id].patch.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ export default eventHandler(async (event) => {
99
}).parse)
1010

1111
// List todos for the current user
12-
const todo = await useDB().update(tables.todos).set({
12+
const todo = await useDrizzle().update(tables.todos).set({
1313
completed
1414
}).where(eq(tables.todos.id, Number(id))).returning().get()
1515

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
export default eventHandler(async () => {
22
// List todos for the current user
3-
const todos = await useDB().select().from(tables.todos).all()
3+
const todos = await useDrizzle().select().from(tables.todos).all()
44

55
return todos
66
})

playground/server/api/todos/index.post.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ export default eventHandler(async (event) => {
44
}).parse)
55

66
// List todos for the current user
7-
const todo = await useDB().insert(tables.todos).values({
7+
const todo = await useDrizzle().insert(tables.todos).values({
88
title,
99
createdAt: new Date()
1010
}).returning().get()

playground/server/plugins/migrations.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
export default defineNitroPlugin(() => {
22
if (import.meta.dev) {
33
onHubReady(async () => {
4-
const db = useDB()
4+
const db = useDrizzle()
55

66
await db.run(sql`CREATE TABLE IF NOT EXISTS todos (
77
id integer PRIMARY KEY NOT NULL,

playground/server/utils/db.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,6 @@ export const tables = {
1313
todos
1414
}
1515

16-
export function useDB() {
16+
export function useDrizzle() {
1717
return drizzle(useDatabase(), { schema: tables })
1818
}

playground/server/utils/zod.ts

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
export { z } from 'zod'

0 commit comments

Comments
 (0)