TypeError: Cannot read property '_update' of undefined
See original GitHub issueDo you want to request a feature or report a bug? BUG
What is the current behavior? TypeError: Cannot read property ‘_update’ of undefined
If the current behavior is a bug, please provide the steps to reproduce. Here’s a sample of code to reproduce the bug
const mongoose = require("mongoose");
const exampleSchema = new mongoose.Schema({
name: { type: String },
value: { type: Number },
}, {
collection: "example",
strict: "throw",
});
const ExampleModel = mongoose.model("Model", exampleSchema);
const example = new ExampleModel({ name: "example 1", value: 1 });
return mongoose
.connect('mongodb://localhost:27017/test', {
useNewUrlParser: true, useUnifiedTopology: true
})
.then(() => example.save())
.then(() => ExampleModel.findOneAndUpdate({
name: "example 1",
} , {
$set: { value: 2 },
}, {
runValidators: true,
})
.select("value")
)
.then((result) => console.log("test OK", result))
.finally(() => mongoose.disconnect())
.catch((error) => console.log("ERROR", error.stack));
What is the expected behavior? we expected the document to be updated
What are the versions of Node.js, Mongoose and MongoDB you are using? Note that “latest” is not a version.
- node : 10.16.0
- mongoose : 5.7.0
- mongoDb: 3.6.12
Issue Analytics
- State:
- Created 4 years ago
- Reactions:4
- Comments:7
Top Results From Across the Web
Cannot Read Property 'update' of undefined - Stack Overflow
When you're creating a new Chest object, you have to use the new operator. So in this code: // Create 4 chests on...
Read more >Cannot Read Property of Undefined in JavaScript - Rollbar
TypeError: Cannot read property of undefined occurs when a property is read or a function is called on an undefined variable.
Read more >Uncaught TypeError: Cannot read property of undefined In
Uncaught TypeError: Cannot read property of undefined error occurs in Chrome when you read a property or call a method on an undefined...
Read more >TypeError: Cannot read property 'update' of undefined #254
It seems that this.popperInstance is not defined in _setContent . I had a quick look at ensureShown function and I don't understand why...
Read more >How to Prevent the Error: Cannot Read Property '0' of Undefined
The Cannot read property xxx of undefined error is one such example. In particular, the Cannot read property 'n' of undefined (where n...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
@kevin-wynn and I just spent all day debugging this. Apparently there an API breaking change in several hooks (in our case, in a
pre
hook) between 5.6 and 5.7. To fix this, lock your version numbers tightly. We we locked our to an older version:Or, if the above comments are correct about
5.6.13
:For reference (and for Google to help find this), here’s the stack trace we got from 5.7.0:
I confirm that version 5.7.1 fix the issue. thank you very much 😃