1
UPDATE
When executing UPDATE
to apply changes, only the minimum data necessary to enforce all peers converge on one view of the data sync across the mesh. (Updating)2
INSERT
While INSERT
operations modify all provided fields, even if they remain unchanged. (Inserting)Updating
To optimize performance and reduce unnecessary overhead, apply most updates in your app through theUPDATE
method instead.
For the full DQL syntax, see Ditto Query Language UPDATE.
UPDATE
operation on the cars
collection:
MAP Data Type
To add aMAP
to a document, use the dot syntax, which allows you to edit multiple child fields within a single MAP
:
Multiple Documents
Modify multiple documents simultaneously based on a specified condition. For example, here is a snippet demonstrating theUPDATE
operation modifying all documents in the cars collection that are currently red, and changing their color to blue.
After the update, you can reference the documents modified by the mutatedDocumentIDs
method on the result
of the update.
Inserting with UPDATE
TheINSERT
operation provides conflict policy options to override default behavior if a document with the same ID already exists.
For the full DQL syntax, see Ditto Query Language INSERT.
ON ID CONFLICT DO UPDATE
policy, inserted documents automatically apply updates for all provided fields.
To optimize performance and reduce unnecessary overhead, apply most data modifications in your app through the
UPDATE
method.Nested MAPs
If you need to represent and organize highly complex data in a hierarchical structure, consider embedding aMAP
within another MAP
to establish a
parent-child relationship within a document as follows.
In 4.11+ with DQL_STRICT_MODE=false
, collection definitions are no longer required.
Read more about strict mode.
INSERT
operation to add a new document with a nested map structure.