How to have @createdBy and @updatedBy annotation in prisma schema (like @updatedAt)

In a nestjs and prisma api, I would like to add audit columns to my database. Writting the mapping to get the user.idin each create/update method of each of my entities is cumbursome. In spring data rest, this is how they do auditing:
@CreatedBy
private User user;

@CreatedDate
private DateTime createdDate;
@CreatedBy
private User user;

@CreatedDate
private DateTime createdDate;
In prisma for example, I can use @updatedAt annotation in my schema to have the updatedData columns without writing code. I would like to have @createdBy and @updatedBy audit annotation, either in prisma or in my nestJS code to audit the connected user.id who made the creation or modification of a row. How is this possible?
0 Replies
No replies yetBe the first to reply to this messageJoin
Want results from more Discord servers?
Add your server