diff --git a/docs/timestamps.md b/docs/timestamps.md index 8dee886d397..d475fa70af3 100644 --- a/docs/timestamps.md +++ b/docs/timestamps.md @@ -199,7 +199,7 @@ Mongoose: users.findOneAndUpdate({}, { '$setOnInsert': { createdAt: new Date("Su Notice the `$setOnInsert` for `createdAt` and `$set` for `updatedAt`. 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). -So, for example, if you want to *only* set `updatedAt` if the document if a new document is created, you can disable the `updatedAt` timestamp and set it yourself as shown below: +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: ```javascript await User.findOneAndUpdate({}, { $setOnInsert: { updatedAt: new Date() } }, {