# Mongoose: VersionError: No matching document found for id "5f..." version 3 modifiedPaths "items"

**Code:** `VersionError: No matching document found for id` · **Category:** MongoDB · **Seen on:** MongoDB, Node.js

Mongoose tried to save a document whose array was changed by someone else since you loaded it (optimistic concurrency).

## Meaning

Arrays use a version key `__v`. A save that modifies arrays after the doc changed elsewhere fails. Reload the document and retry, use atomic update operators (`$push`, `$set`) with `updateOne` instead of load-modify-save, or disable versioning for the schema (`versionKey: false`) if safe.

## Common causes

- Two requests modifying the same document array
- Load-modify-save race
- Stale document held in memory
- Array element order changes
- Retries replaying old versions

## Quick fix

1. Use `updateOne({_id}, {$push: { items: item }})`
2. Reload and reapply the change
3. Retry on VersionError

## Detailed fix by platform

### Node.js

1. `await Order.updateOne({ _id }, { $push: { items: item } });`

## How to diagnose

1. **Race** — Concurrent writers?
2. **Update** — Atomic operator possible?
3. **Retry** — Implemented?

---
Source: [WhatIsMyError](https://whatismyerror.com/errors/mongodb/mongoose-version-error-no-matching-document)
