Skip to content

Commit

Permalink
fix(timestamps): avoid setting createdAt on documents that already …
Browse files Browse the repository at this point in the history
…exist but dont have createdAt

Fix #11024
  • Loading branch information
vkarpov15 committed Dec 27, 2021
1 parent a738440 commit 4cfc4d6
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion lib/helpers/timestamps/setupTimestamps.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ module.exports = function setupTimestamps(schema, timestamps) {
(this.ownerDocument ? this.ownerDocument() : this).constructor.base.now();
const auto_id = this._id && this._id.auto;

if (!skipCreatedAt && createdAt && !this.get(createdAt) && this.$__isSelected(createdAt)) {
if (!skipCreatedAt && this.isNew && createdAt && !this.get(createdAt) && this.$__isSelected(createdAt)) {
this.$set(createdAt, auto_id ? this._id.getTimestamp() : defaultTimestamp);
}

Expand Down

0 comments on commit 4cfc4d6

Please sign in to comment.