A simple SQL-like query language designed specifically for the features and capabilities of the Ditto platform.
ditto.store.execute(...)
and
ditto.store.observeLocal(...)
APIs. These operations are only performed
against the local data store and can be used alongside existing legacy builder
queries.
.subscribe()
find(...)
, findById(...)
, upsert(...)
, and so on.DQL_STRICT_MODE
on all devices
observe
: Use DQL’s registerObserver
statements instead of the legacy observe
method.exec
queries: Update your legacy execution queries to their DQL equivalents.INSERT ... DO MERGE
statements behave the same as the legacy query builder upsert
.
transaction()
method if you need to execute multiple database operations
in one atomic transaction. Read more at Transactions
UPDATE
statement in DQL. Instead, use INSERT ... DO MERGE
as follows:
CBOR
) is the same as the legacy query builder, so on-disk format is comatible between both query engines.
However, when using DQL, you must implement your own serialization for the
INSERT
and SELECT
statements. Ditto no longer supports built-in variations
such as Codable in Swift.
For example, the following code shows how to use Swift’s JSONDecoder
to serialize
a document before inserting it into the database:
JSONDecoder
to deserialize a document when reading
a QueryResultItem
from the database:
ditto.sync.registerSubscription(...)
API on v4.5 or later will only be able to sync with other devices on v4.5 or later.
Ensure all devices in your production environment are using v4.5 and above
Success!
ditto.sync.registerSubscription(...)
ditto.store.collection("cars").find("cars == 'blue'").subscribe()