Has anyone worked with a custom implementation of ...
# orm-help
γ
Has anyone worked with a custom implementation of Soft-Delete functionality? How can I filter in middleware relations like
where: { deletedAt: null }
? Middleware is only called once on
findUnique()
call, but I want a middleware to run on every query operation. The following:
Copy code
await prisma.cart.findFirst({
  where: { id: 107 },
  include: { foods: true } },
});
will call middleware
prisma.$use()
only once, and not for the DB query when fetching the relation
foods
t
maybe you can skip middleware and go with
repo.findMany({ where: { id, deleted: false } })
γ
Yeah, but I have 50+ models that implement the soft-delete methodology. I should filter the deleted ones all manually, whenever I query the DB
I want to use middleware to avoid such impractical applications
t
I understand and have no idea how you can achieve it with middleware; sorry :(
γ
Yeah, I understand