Use updateOne(filter, update) to modify the first matching document or updateMany(filter, update) to update all matching documents. Always wrap field changes inside an update operator like $set so you don't overwrite the entire document.
ADVERTISEMENT