UPDATE
This article provides an overview of the updating documents using the UPDATE and INSERT DQL operations.
Update operations ensure that only the minimum data necessary to enforce all peers converge on one view of the data replicates across the mesh:
For complete DQL syntax, see Ditto Query Language (DQL) > UPDATE
UPDATE operates over a condition that allows multiple documents to be updated at the same time.
In the following example, all the red cars in the cars collection are updated to be blue. The documents updated can be referenced by using the mutatedDocumentIDs method on the result.
The INSERT operation provides conflict policy options to override default behavior if a document with the same ID already exists. By using the ON ID CONFLICT DO UPDATE policy, inserted documents automatically apply updates for all provided fields.
Updating data using an INSERT operation may cause performance to degrade. This is because when you use an INSERT operation to modify data, all provided fields update, even if they remain unchanged.
To optimize performance and reduce unnecessary overhead, apply most updates in your app through the UPDATE method instead.
For complete DQL syntax, see Ditto Query Language (DQL) > INSERT