Skip to content

Commit 81794a3

Browse files
committed
feat: add prisma and sqlite database
1 parent e9ba73b commit 81794a3

File tree

9 files changed

+88
-1
lines changed

9 files changed

+88
-1
lines changed

package-lock.json

Lines changed: 53 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
"lint": "next lint"
1010
},
1111
"dependencies": {
12+
"@prisma/client": "^4.16.2",
1213
"@radix-ui/react-slot": "^1.0.2",
1314
"@types/node": "20.4.1",
1415
"@types/react": "18.2.14",
@@ -27,5 +28,8 @@
2728
"tailwindcss": "3.3.2",
2829
"tailwindcss-animate": "^1.0.6",
2930
"typescript": "5.1.6"
31+
},
32+
"devDependencies": {
33+
"prisma": "^4.16.2"
3034
}
3135
}

prisma/dev.db

20 KB
Binary file not shown.

prisma/dev.db-journal

8.52 KB
Binary file not shown.
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
-- CreateTable
2+
CREATE TABLE "User" (
3+
"id" INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,
4+
"createdAt" DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
5+
"name" TEXT
6+
);

prisma/migrations/migration_lock.toml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# Please do not edit this file manually
2+
# It should be added in your version-control system (i.e. Git)
3+
provider = "sqlite"

prisma/schema.prisma

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
generator client {
2+
provider = "prisma-client-js"
3+
}
4+
5+
datasource db {
6+
provider = "sqlite"
7+
url = "file:./dev.db"
8+
}
9+
10+
model User {
11+
id Int @id @default(autoincrement())
12+
createdAt DateTime @default(now())
13+
name String?
14+
}

src/app/page.tsx

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
11
import { Button } from "@/components/ui/button";
2+
import { prisma } from "@/lib/prisma";
3+
4+
export default async function Home() {
5+
const users = await prisma.user.findMany();
6+
console.log(users);
27

3-
export default function Home() {
48
return (
59
<main className="flex min-h-screen flex-col items-center justify-between p-24">
610
<Button>Button</Button>

src/lib/prisma.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
import { PrismaClient } from "@prisma/client";
2+
3+
export const prisma = new PrismaClient();

0 commit comments

Comments
 (0)