We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
What is the current behavior?
When replacing an existing subdocument with timestamps enabled, if none of the fields within the subdocument change, then timestamps are lost/not set.
If the current behavior is a bug, please provide the steps to reproduce.
const mongoose = require('mongoose'); const assert = require('assert'); const childSchema = new mongoose.Schema({ name: String }, { timestamps: true, _id: false}); const testSchema = new mongoose.Schema({ child: childSchema, age: Number}); async function run() { await mongoose.connect('mongodb://localhost:27017'); await mongoose.connection.dropDatabase(); const Test = mongoose.model('Test', testSchema); const doc = await Test.create({ age: 10, child: { name: 'foo' } }); assert(typeof doc.child.updatedAt !== "undefined"); // this works fine doc.child = { name: "foo" }; await doc.save(); assert(typeof doc.child.updatedAt !== "undefined"); // fails } run();
What is the expected behavior?
If timestamps are enabled on a subdocument, they should never be undefined after save'ing the document.
timestamps
save
What are the versions of Node.js, Mongoose and MongoDB you are using? Note that "latest" is not a version.
Tested this on 6.2.10. This worked as expected in 5.9.11, which we are upgrading from.
6.2.10
5.9.11
The text was updated successfully, but these errors were encountered:
Potentially related to #11603?
Sorry, something went wrong.
Also, running doc.child.markModified("name"); before the save makes this test case pass, but doc.markModified("child.name"); does not.
doc.child.markModified("name");
doc.markModified("child.name");
This was fixed in v6.3.1 with #11603. Please upgrade to >= 6.3.1 for the fix.
>= 6.3.1
No branches or pull requests
What is the current behavior?
When replacing an existing subdocument with timestamps enabled, if none of the fields within the subdocument change, then timestamps are lost/not set.
If the current behavior is a bug, please provide the steps to reproduce.
What is the expected behavior?
If
timestamps
are enabled on a subdocument, they should never be undefined aftersave
'ing the document.What are the versions of Node.js, Mongoose and MongoDB you are using? Note that "latest" is not a version.
Tested this on
6.2.10
. This worked as expected in5.9.11
, which we are upgrading from.The text was updated successfully, but these errors were encountered: