Readonly
dittoThe Ditto instance this store belongs to.
Readonly
observersAll currently active store observers.
Note: Manage store observers using registerObserver() to register a new store observer and StoreObserver.cancel() to remove an existing store observer.
Returns the collection for the given name. If the collection doesn't exist yet, it will be created automatically as soon as the first entry is inserted. A collection name is valid if:
Returns the names of all available collections in the store of the related Ditto instance.
Returns an object that lets you fetch or observe the collections in the store.
A PendingCollectionsOperation object that you can use to fetch or observe the collections in the store
Executes a DQL query and returns matching items as a query result.
a string containing a valid query expressed in DQL.
Optional
queryArguments: DQLQueryArgumentsan object of values keyed by the placeholder name
without the leading :
. Example: { "name": "John" }
for a query like
SELECT * FROM people WHERE name = :name
.
a promise for a QueryResult containing a QueryResultItem for each match.
DittoError query/invalid
: if query
argument is not a
string or not valid DQL.
DittoError query/arguments-invalid
: if queryArguments
argument is invalid (e.g. contains unsupported types).
DittoError may throw other errors.
Register a handler to be called whenever a query's results change in the local store.
Convenience method, same as
registerObserverWithSignalNext(),
except that here, the next invocation of the observation handler is
triggered automatically instead of having to call the passed in
signalNext
function.
a string containing a valid query expressed in DQL.
a function that is called whenever the query's results change. The function is passed a QueryResult containing a QueryResultItem for each match.
Optional
queryArguments: DQLQueryArgumentsan object of values keyed by the placeholder name
without the leading :
. Example: { "name": "Joanna" }
for a query like
SELECT * FROM people WHERE name = :name
.
a StoreObserver that can be used to cancel the observation.
DittoError query/invalid
: if query
argument is not a
string or not valid DQL.
DittoError query/arguments-invalid
: if queryArguments
argument is invalid (e.g. contains unsupported types).
DittoError query/unsupported
: if the query is not a
SELECT
query.
DittoError may throw other errors.
Registers and returns a store observer for a query, configuring Ditto to
trigger the passed in observation handler whenever documents in the local
store change such that the result of the matching query changes. The passed
in query must be a SELECT
query.
Here, a function is passed as an additional argument to the observation handler. Call this function as soon as the observation handler is ready to process the the next change event. This allows the observation handler to control how frequently it is called. See registerObserver() for a convenience method that automatically signals the next invocation.
The first invocation of observationHandler
will always happen after this
method has returned.
a string containing a valid query expressed in DQL.
an observation handler function that is called whenever the query's results change. The function is passed a QueryResult containing a QueryResultItem for each match.
Optional
queryArguments: DQLQueryArgumentsan object of values keyed by the placeholder name
without the leading :
. Example: { "name": "Joanna" }
for a query like
SELECT * FROM people WHERE name = :name
.
a StoreObserver that can be used to cancel the observation.
DittoError query/invalid
: if query
argument is not a
string or not valid DQL.
DittoError query/arguments-invalid
: if queryArguments
argument is invalid (e.g. contains unsupported types).
DittoError query/unsupported
: if the query is not a
SELECT
query.
DittoError may throw other errors.
Initiate a write transaction in a callback.
Allows you to group multiple operations together that affect multiple documents, potentially across multiple collections.
is given access to a write transaction object that can be used to perform operations on the store.
a list of WriteTransactionResult
s. There is a result for each operation performed as part of the write transaction.
The entrypoint for all actions that relate to data stored by Ditto. Provides access to collections, a write transaction API, and a query hash API.
You don't create one directly but can access it from a particular Ditto instance via its store property.