Suggest an editImprove this articleRefine the answer for “How does replaceOne() differ from updateOne()?”. Your changes go to moderation before they’re published.Approval requiredContentWhat you’re changing🇺🇸EN🇺🇦UAPreviewTitle (EN)Short answer (EN)The difference is that `updateOne()` only changes the specified fields, while `replaceOne()` fully replaces the document with a new one (except for `_id`): if the old document had other fields, they disappear. **Key point:** the simple way to remember it - `updateOne()` updates partially, `replaceOne()` overwrites the whole document.Shown above the full answer for quick recall.Answer (EN)ImageThe difference is that `updateOne()` **only changes the specified fields**, while `replaceOne()` **fully replaces the document with a new one**. ### In short: | Method | What it does | |---|---| | `updateOne()` | Updates the chosen fields using operators (`$set`, `$inc`, `$unset`, etc.) | | `replaceOne()` | Fully replaces the entire document with a new one, except for `_id` | ### `updateOne()` example (a partial update): ```js db.users.updateOne( { name: "Alex" }, { $set: { age: 26 } } ) ``` - only the `age` field changes, everything else stays as it was. ### `replaceOne()` example (a full replacement): ```js db.users.replaceOne( { name: "Alex" }, { name: "Alex", age: 26, verified: true } ) ``` - the old document is deleted and replaced by the new one (if the old one had other fields, they're gone). ### The summary for a junior developer: `updateOne()` updates partially. `replaceOne()` overwrites the document entirely.For the reviewerNote to the moderator (optional)Visible only to the moderator. Helps review go faster.