Skip to content

Commit 6745b69

Browse files
committed
Merge branch '5.x'
2 parents 8dfc4cc + d2b846f commit 6745b69

File tree

3 files changed

+7
-2
lines changed

3 files changed

+7
-2
lines changed

CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
5.13.14 / 2021-12-27
2+
====================
3+
* fix(timestamps): avoid setting createdAt on documents that already exist but dont have createdAt #11024
4+
* docs(models): fix up nModified example for 5.x #11055
5+
16
6.1.3 / 2021-12-21
27
==================
38
* perf(populate): avoid duplicate model names when using refPath to avoid O(n^2) memory growth with number of array elements #10983

docs/models.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ database without returning them to your application. See the
103103

104104
```javascript
105105
Tank.updateOne({ size: 'large' }, { name: 'T-90' }, function(err, res) {
106-
// Updated at most one doc, `res.modifiedCount` contains the number
106+
// Updated at most one doc, `res.nModified` contains the number
107107
// of docs that MongoDB updated
108108
});
109109
```

lib/helpers/timestamps/setupTimestamps.js

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

52-
if (!skipCreatedAt && createdAt && !this.$__getValue(createdAt) && this.$__isSelected(createdAt)) {
52+
if (!skipCreatedAt && this.isNew && createdAt && !this.$__getValue(createdAt) && this.$__isSelected(createdAt)) {
5353
this.$set(createdAt, auto_id ? this._id.getTimestamp() : defaultTimestamp);
5454
}
5555

0 commit comments

Comments
 (0)