Hey folks, I was wondering if anyone has an opinio...
# orm-help
j
Hey folks, I was wondering if anyone has an opinionated way of implementing an audit trail type of feature. Is this something you would use prisma for, with say a database trigger or some sort? Or more an API layer concern mostly?
j
That really depends on what you want to achieve and what your access patterns to your database look like - if there are other apps besides Prisma using ones, you need to go with something in the database.
Prisma 2 has middlewares, which can be used to implement such a feature on an app level if you want.
j
Hi Janpio, thanks for answering a rather vague question of mine. It seems for the moment that Prisma will be the only one to access the DB, so it might be interesting to pursue maintainijng some archive of who did what in the application. Either way, thanks!
j
Yeah, then a middleware would indeed work. You'll have to decide then if you want to do that via versioning in the same table or have an additional copy of the table as an audit archive where you keep the things - many possible patterns. But with middleware you can react to all queries that happen via Prisma Client in whatever way you want.
j
Im gonna have a look at this soon, thank you 😄