Skip to content

Commit 4cfc4d6

Browse files
committed
fix(timestamps): avoid setting createdAt on documents that already exist but dont have createdAt
Fix #11024
1 parent a738440 commit 4cfc4d6

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

lib/helpers/timestamps/setupTimestamps.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ module.exports = function setupTimestamps(schema, timestamps) {
5151
(this.ownerDocument ? this.ownerDocument() : this).constructor.base.now();
5252
const auto_id = this._id && this._id.auto;
5353

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

0 commit comments

Comments
 (0)