Skip to content

Access document in pre hook query middleware #8218

Closed
@BenjErgizerBunny

Description

@BenjErgizerBunny

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

Documentation Issue

What is the current behavior?

In a pre hook for findOneAndUpdate I need to get the document being saved. I can see there is an issue that was closed previously for this that simply had a link to the documentation, however the documentation for this is not straight forward at all. It does describe how "this" functions in query middleware but I do not see anywhere in the documentation that says how to actually get the document in query middleware.

I generally find the Mongoose documentation to be very difficult to read which makes it significantly harder and less attractive to use Mongoose.

Can someone please indicate how to access the document in the a pre hook for query middleware?

#7497

Metadata

Metadata

Assignees

No one assigned

    Labels

    docsThis issue is due to a mistake or omission in the mongoosejs.com documentation

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions