enums represented as simple tables
model User {
name String
role Role @default(BAISC)
}
enum Role {
BAISC
EDITOR
ADMIN
}
apply constrains or functions on fields
@id
: make field primary key@unique
: make field unique@map('')
: change field name in database@updatedAt
: assign currrent timestamp when update row@default()
which use functions like autoincrement()
for incremental numbers or uuid()
for random uuid which is better for security or now()
which enter current timestampmodel User {
name String @id @default(uuid())
// change table name in database
@@map("users")
// rows with same two fields values should be unique
@@unique([age, name])
// create index on field/s
@@index([email])
// remove above primary key (id), and use id from these two fields
@@id([name, age])
}