-
-
Notifications
You must be signed in to change notification settings - Fork 3.9k
Closed
Labels
confirmed-bugWe've confirmed this is a bug in Mongoose and will fix it.We've confirmed this is a bug in Mongoose and will fix it.
Milestone
Description
Do you want to request a feature or report a bug?
Bug
What is the current behavior?
this context in hooks are not of type Query anymore
If the current behavior is a bug, please provide the steps to reproduce.
query hook:
mySchema.pre('findOneAndUpdate', async function setDefaultOptions(this: any) {
console.log(this instanceof Query) // false, used to be true up to mongoose 5.4.22
})
call findOneAndUpdate
await model(message.messageType).findOneAndUpdate({_id: {$exists: false}}, newMessage, {upsert: true})
What is the expected behavior?
behaviour should not change between minor versions of mongoose
query hooks should be of type Query
What are the versions of Node.js, Mongoose and MongoDB you are using? Note that "latest" is not a version.
mongoose 5.5.6 is broken (and earlier)
mongoose 5.4.22 is the last tested working version
# mongod --version
db version v4.0.9
Metadata
Metadata
Assignees
Labels
confirmed-bugWe've confirmed this is a bug in Mongoose and will fix it.We've confirmed this is a bug in Mongoose and will fix it.