Gunawan
PPrisma
•Created by Gunawan on 1/3/2025 in #help-and-questions
Handle auto filter base on status of model (prisma and nestjs)
In my project, I have some roles, they are Student, Lecture, and Admin. I also have some model with status.
Status = enum(Public, Private, Archive)
Role= enum(Student, Private,Public)
I have University and Course model with their own status, I want the user with role Student only have access for University/Course with Public status. Lecture also only have access to Course with Public and Private Status.
If I only have 1 controller/route for all roles, how I can implement this requirement with good performance?
I was able to create a middleware for every routes to determine the process base on role but in middleware I need to make a query select, and that is my concern because it make me select the item more than one, (1 for middleware, >=1 in service)
4 replies