Skip to content

Commit 77bd781

Browse files
authored
Update timestamps.md
1 parent 35fd920 commit 77bd781

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

docs/timestamps.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -199,7 +199,7 @@ Mongoose: users.findOneAndUpdate({}, { '$setOnInsert': { createdAt: new Date("Su
199199

200200
Notice the `$setOnInsert` for `createdAt` and `$set` for `updatedAt`.
201201
MongoDB's [`$setOnInsert` operator](https://www.mongodb.com/docs/manual/reference/operator/update/setOnInsert/) applies the update only if a new document is [upserted](https://masteringjs.io/tutorials/mongoose/upsert).
202-
So, for example, if you want to *only* set `updatedAt` of the document if a new document is created, you can disable the `updatedAt` timestamp and set it yourself as shown below:
202+
So, for example, if you want to *only* set `updatedAt` if a new document is created, you can disable the `updatedAt` timestamp and set it yourself as shown below:
203203

204204
```javascript
205205
await User.findOneAndUpdate({}, { $setOnInsert: { updatedAt: new Date() } }, {

0 commit comments

Comments
 (0)