An upsert inserts a record when it is absent and updates it when present. In a CQRS view repository, create and update methods commonly use upserts because related events may arrive out of order: a create handler can find a record already created by another aggregate, while an update handler may run before the record exists. Upserts address uncertain record existence; methods still need to handle concurrent and duplicate events correctly. section 13.3.3
Out-of-order events
A create event handler may find that a related aggregate’s event already created the record. Using an upsert lets the handler update that existing record instead of assuming it is absent. section 13.3.3



