Learn how to access data in Ditto, including creating, reading, updating, and removing data.
ditto.store.execute()
method in each of the Ditto SDKs, or via the /store/execute
endpoint in the Ditto HTTP API.
You can read more about DQL in the DQL documentation.
INSERT INTO
DQL statement.
For example, you can execute a query like:
SELECT
statement.
For example:
WHERE
clause allows you to filter the results based on specific criteria.
For example:
ditto.store.registerObserver()
method in each of the Ditto SDKs.
By specifying a DQL SELECT
statement, Ditto will notify the observer when the results of the query change. It will provide these results as a callback containing the full dataset of the results of the query, which can then be passed directly to the UI framework of your choice, which will often handle efficient updates to the UI based on the changes.
For more examples of reacting to data changes in your language of choice, please see Observing Data Changes.
_id
123
to blue. We could run:
_id
to update a specific record, but you could update multiple documents at once if they match a filter.
Only the specified fields are modified — all other fields in the document remain unchanged.
When you execute an update, the changes are applied to the local store immediately. Ditto tracks this change and will propagate it to other peers on the network during the next sync. This means your update is done offline-safe: you can update data with no internet, and Ditto will queue that change to send out when connectivity is available. Each update operation in Ditto is idempotent on the target documents (applying the same update again will have no effect if the data is already updated) and will be merged with any concurrent changes from other devices. In essence, updating documents with Ditto is straightforward - you specify what to change and let Ditto handle applying it locally and syncing it globally.
For more examples of updating data in your language of choice, please see Updating Documents.
isDeleted
field to the document to indicate that it has been deleted, and then when specifying your subscription and setting up local queries/observers you can filter out documents where isDeleted
is true.
For example:
.remove()
method in the Ditto SDK, and in Ditto Server using the TOMBSTONE
DQL operation:
DELETE
operation in Ditto 4.10.Tombstones will also be cleaned up automatically in Ditto 4.10.EVICT
DQL operation.
For example: