Skip to content

[Feature] option to disable running pre/post hooks #8768

@AbdelrahmanHafez

Description

@AbdelrahmanHafez

I am not sure whether this is present or not, but it would be great if we have a way to optionally disable running middlewares, a couple of use cases that I could think of is for internal use in the library, this would help us avoid situations like #8739.

Other developers could also use this in their applications if they need to run a query without triggering middlewares, or inside the logic of the middleware in itself to avoid an infinite loop such as the custom option in #8756 (comment).

Considering the following API:

User.findOne({ name: 'John' }, null, { middlewares: false })

Later on, we could make it so that the options accept an object

{ middlewares: { pre: true, post: false } }

Metadata

Metadata

Assignees

No one assigned

    Labels

    new featureThis change adds new functionality, like a new method or class

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions