-
-
Notifications
You must be signed in to change notification settings - Fork 4k
Description
Prerequisites
- I have written a descriptive issue title
Mongoose version
6.13.8
Node.js version
22.21.1
MongoDB version
8.x
Operating system
Windows
Operating system version (i.e. 20.04, 11.3, 10)
11
Issue
I needed some help understanding the difference between the options passed to doc.remove() in Mongoose 6.x vs doc.deleteOne(). From what I know, "remove" worked similar to "save", in that any options passed when calling doc.remove(options) were available in the pre middleware. However, since I have switched to using "deleteOne", and attaching document middleware on it, the options object is no longer available as the second argument in pre middleware. In fact, the document instance itself is the second argument.
I am maintaining some code which used to pass custom options (for example, request identifiers) when deleting the document, that I need to access in the pre/post middleware. Is there no way to access the options object similar to remove/save?