Hi! I am looking for a common filtering method, li...
# random
t
Hi! I am looking for a common filtering method, like Laravel’s scope, that can be given to queries against a specific model. there is no such functionality as laravel’s method chain, so I am trying to figure out how to implement it. Any ideas? I would be very happy to receive your advice. https://laravel.com/docs/5.8/eloquent#query-scopes
c
Most likely the best analog is Prisma’s middleware functionality: https://www.prisma.io/docs/concepts/components/prisma-client/middleware/soft-delete-middleware If you don’t want it to be so global, the best thing would probably be to build a query transformer of some kind that takes the Where clause object and makes the modifications to the object needed to match the scope desired, something like:
Copy code
await prisma.user.findMany({
  where: withoutSoftDeletedEntities({
    id: 302,
  }),
})
🙌 1
👀 1
t
Hi @Casey Chow Thanks for getting back to me! This looks awesome! I’ll investigate the documentation ASAP! Thanks also for the suggestion to customize the query. We have actually decided to do this for our current project.
🙌 1