-
-
Notifications
You must be signed in to change notification settings - Fork 3.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Pushing an object into a nested array makes mongoose crash #6398
Milestone
Comments
Another way of updating the array does not work as expected either: var mongoose = require("mongoose");
var model = mongoose.model("TestModel", new mongoose.Schema({
name: String,
array: [[{key: String, value: Number}]]
}));
mongoose.connect("mongodb://localhost/test");
mongoose.connection.on("connected", async () => {
console.log("Mongoose connected");
await new model({name: "small", array: [[
{key: "answer", value: 42}
]]}).save();
var doc = await model.findOne().exec();
doc.array = [[
{key: "answer", value: 42},
{key: "lucky", value: 7}
]];
await doc.save();
process.exit(0);
}); This throws a ValidationError instead:
|
Thanks for reporting, will investigate ASAP 👍 |
vkarpov15
added a commit
that referenced
this issue
Apr 29, 2018
vkarpov15
added a commit
that referenced
this issue
Nov 24, 2019
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Do you want to request a feature or report a bug? Bug 🐛
What is the current behavior?
If the current behavior is a bug, please provide the steps to reproduce.
Pushing an object into a nested array (as introduced in #1361) makes mongoose crash. Standalone example:
This throws a TypeError:
What is the expected behavior?
The document should be updated without throwing a TypeError.
Please mention your node.js, mongoose and MongoDB version.
The text was updated successfully, but these errors were encountered: