Many update operations in MongoDB have the potential to be upserts. An upsert is a combination of an insert and an update.
It works like this: You perform an update operation based on filter criteria, and if there are any matches, only the matched documents are updated, but if there are no matches, then a new document is inserted.
Continue reading