Commit a7a46d8c authored by Nawasan Wisitsingkhon's avatar Nawasan Wisitsingkhon

setup prisma to connect to mysql database

parent 9d0ed739
# Environment variables declared in this file are automatically made available to Prisma.
# See the documentation for more detail: https://pris.ly/d/prisma-schema#accessing-environment-variables-from-the-schema
# Prisma supports the native connection string format for PostgreSQL, MySQL, SQLite, SQL Server, MongoDB and CockroachDB.
# See the documentation for all the connection string options: https://pris.ly/d/connection-strings
DATABASE_URL="mysql://<username>:<password>@localhost:3306/<db_name>?schema=public"
\ No newline at end of file
......@@ -25,6 +25,7 @@ yarn-debug.log*
yarn-error.log*
# local env files
.env
.env*.local
# vercel
......
import { Request, Response } from "express";
const WelcomeController = {
/**
*
......
import { PrismaClient } from "@prisma/client";
const db = new PrismaClient();
export default db;
\ No newline at end of file
......@@ -9,8 +9,10 @@
"lint": "next lint"
},
"dependencies": {
"@prisma/client": "5.3.1",
"express": "^4.18.2",
"next": "latest",
"prisma": "^5.3.1",
"react": "latest",
"react-dom": "latest"
},
......
......@@ -5,12 +5,18 @@ settings:
excludeLinksFromLockfile: false
dependencies:
'@prisma/client':
specifier: 5.3.1
version: 5.3.1(prisma@5.3.1)
express:
specifier: ^4.18.2
version: 4.18.2
next:
specifier: latest
version: 13.5.3(react-dom@18.2.0)(react@18.2.0)
prisma:
specifier: ^5.3.1
version: 5.3.1
react:
specifier: latest
version: 18.2.0
......@@ -253,6 +259,29 @@ packages:
fastq: 1.15.0
dev: true
/@prisma/client@5.3.1(prisma@5.3.1):
resolution: {integrity: sha512-ArOKjHwdFZIe1cGU56oIfy7wRuTn0FfZjGuU/AjgEBOQh+4rDkB6nF+AGHP8KaVpkBIiHGPQh3IpwQ3xDMdO0Q==}
engines: {node: '>=16.13'}
requiresBuild: true
peerDependencies:
prisma: '*'
peerDependenciesMeta:
prisma:
optional: true
dependencies:
'@prisma/engines-version': 5.3.1-2.61e140623197a131c2a6189271ffee05a7aa9a59
prisma: 5.3.1
dev: false
/@prisma/engines-version@5.3.1-2.61e140623197a131c2a6189271ffee05a7aa9a59:
resolution: {integrity: sha512-y5qbUi3ql2Xg7XraqcXEdMHh0MocBfnBzDn5GbV1xk23S3Mq8MGs+VjacTNiBh3dtEdUERCrUUG7Z3QaJ+h79w==}
dev: false
/@prisma/engines@5.3.1:
resolution: {integrity: sha512-6QkILNyfeeN67BNEPEtkgh3Xo2tm6D7V+UhrkBbRHqKw9CTaz/vvTP/ROwYSP/3JT2MtIutZm/EnhxUiuOPVDA==}
requiresBuild: true
dev: false
/@rushstack/eslint-patch@1.5.0:
resolution: {integrity: sha512-EF3948ckf3f5uPgYbQ6GhyA56Dmv8yg0+ir+BroRjwdxyZJsekhZzawOecC2rOTPCz173t7ZcR1HHZu0dZgOCw==}
dev: true
......@@ -2249,6 +2278,15 @@ packages:
engines: {node: '>= 0.8.0'}
dev: true
/prisma@5.3.1:
resolution: {integrity: sha512-Wp2msQIlMPHe+5k5Od6xnsI/WNG7UJGgFUJgqv/ygc7kOECZapcSz/iU4NIEzISs3H1W9sFLjAPbg/gOqqtB7A==}
engines: {node: '>=16.13'}
hasBin: true
requiresBuild: true
dependencies:
'@prisma/engines': 5.3.1
dev: false
/prop-types@15.8.1:
resolution: {integrity: sha512-oj87CgZICdulUohogVAR7AjlC0327U4el4L6eAvOqCeudMDVU0NThNaV+b9Df4dXgSP1gXMTnPdhfe/2qDH5cg==}
dependencies:
......
-- CreateTable
CREATE TABLE `users` (
`id` INTEGER NOT NULL AUTO_INCREMENT,
`name` VARCHAR(191) NOT NULL,
`username` VARCHAR(191) NOT NULL,
`password` VARCHAR(191) NOT NULL,
UNIQUE INDEX `users_username_key`(`username`),
PRIMARY KEY (`id`)
) DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
# Please do not edit this file manually
# It should be added in your version-control system (i.e. Git)
provider = "mysql"
\ No newline at end of file
// This is your Prisma schema file,
// learn more about it in the docs: https://pris.ly/d/prisma-schema
generator client {
provider = "prisma-client-js"
}
datasource db {
provider = "mysql"
url = env("DATABASE_URL")
}
model users {
id Int @id @default(autoincrement())
name String
username String @unique
password String
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment