Skip to content

Schema.pre(Array, fn), like Schema.pre(['save', 'validate']) #7803

@Mangosteen-Yang

Description

@Mangosteen-Yang

Do you want to request a feature or report a bug?
feature

What is the current behavior?
If I want to use middleware in a model I need to define specific operation like 'save', 'findOneAndUpdate', 'update'.

What is the expected behavior?
I hope there can exist a middleware called 'saveOrUpdate', which means whatever create a new document or update an existing document will trigger this middleware.

What are the versions of Node.js, Mongoose and MongoDB you are using? Note that "latest" is not a version.
Node.js 12.0
Mongoose 5.5.8
MongoDB 4.0.9

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementThis issue is a user-facing general improvement that doesn't fix a bug or add a new feature

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions