generator client {
provider = "prisma-client-js"
}
datasource db {
provider = "mysql"
url = env("DATABASE_URL")
}
model User {
id Int @id @default(autoincrement())
phone Int? @unique
email String? @unique
name String
avatar String?
createdAt DateTime @default(now())
}
조회할 때 특정 값을 기준으로 데이터를 찾을 때 빠르게 조회할 수 있음
model Product {
id Int @id @default(autoincrement())
user User @relation(fields: [userId], references: [id], onDelete: Cascade)
userId Int
...
@@index([userId])
}
@@index([userId])
https://www.prisma.io/docs/concepts/components/prisma-schema/relations/relation-mode