updateOne() modifies one document matching a filter. It accepts a filter, an update document, and optional options; with upsert: true, it creates a document when no match exists. section 4.3
Use updateOne() with precise filters and update operators:
- Target a document with identifiers or other criteria; an empty filter updates the first returned document, so verify selection. section 4.3
- Use $set to change a field or create it when absent, and use $inc to increment or decrement a numeric value. section 4.3.1
- Make upsert filters uniquely indexed when repeated upserts must not create multiple documents. section 4.3
Update a route’s aircraft
The filter identifies a route by airline, airports, and its current aircraft. The $set operation then changes airplane from "747" to "A380". section 4.3.1
Increment route stops
A route filter can identify a flight with stops: 0, while $inc changes stops to 1. section 4.3.1
