Sarmad
Sarmad
WWasp-lang
Created by Sarmad on 10/15/2024 in #đŸ™‹questions
CreatedAt, UpdatedAt, DeletedAt
Hey Guys! I want to ask how do you manage the timestamps for your models. I wanted to have createdAt, updatedAt, and deletedAt attribute for all my models but adding these fields manually to all models seems a bit tedious and against the DRY principle. Is there a better way? I thought of creating a base model with these defined and extending all other models from it but prisma doesnt support inheritence either. Before adding these properties in each model, i would like to ask for some guidance as i am new to this framework. below is my Task model. model Task { id Int @id @default(autoincrement()) description String isDone Boolean @default(false) createdAt DateTime @default(now()) updatedAt DateTime @updatedAt deletedAt DateTime? } P.S: DeletedAt is ofcourse in case of soft delete which is my requirement, in case of hard delete the record simply doesnt exist Regards, Sarmad
11 replies