Oliver
08/04/2022, 3:42 PMAuditLogEntry
. Im not sure this is 100% Prisma related but I'm curious if you believe this is viable?
Specifically, I wonder if it will be too much data if a few hundred users click around all day and create AuditLogEntry
everytime they load a page (read from a table), which they will do rather often.
Thanks!
EDIT: This is how I imagine the model to look like, to give an idea of the data size:
model AuditLogEntry {
id String @id @default(cuid())
createdAt DateTime @default(now()) @map("created_at")
authorId String @map("author_id")
author User @relation(fields: [authorId], references: [id], onDelete: Cascade)
patient Patient? @relation(fields: [patientId], references: [id], onDelete: Cascade)
patientId String? @map("patient_id")
subject Subject?
action Action?
title String
description String
@@map("audit_log_entries")
}
Nathan Froese
08/04/2022, 4:00 PMOliver
08/04/2022, 4:09 PMLloyd Richards
08/04/2022, 6:03 PMmodel Post {
id String @id @default(cuid())
...
logs AuditLogEntry[]
}
model AuditLogEntry {
id String @id @default(cuid())
...
post Post? @relation(fields: [post_id], references: [id])
post_id String?
... (other CRUD Models?)
@@map("audit_log_entries")
}
const logData = (action)=>{
logs: {
create: {
action,
author: {
connect: { autherID },
},
},
},
};
const result = await prisma.post.create({
data:{
...PostData,
...logData("CREATE"),
}
});
being able to create multiple nested relations is super nice with PrismaNurul
08/05/2022, 2:45 PM