pub struct Store { /* private fields */ }
Expand description

Store provides access to Collections and a write transaction API.

Implementations

Returns a Collection with the provided name. A collection name is valid if :

  • its length is less than 100
  • it is not empty
  • it does not contain the char ‘\0’
  • it does not begin with “$TS_”

Returns an object that lets you fetch or observe the collections in the store.

Allows you to group multiple operations together that affect multiple documents, potentially across multiple collections, without auto-committing on each operation.

At the end of the batch of operations, either batch.commit_changes or batch.revert_changes must be called.

Example
ditto.store().with_batched_write(|batch| {
    let mut foo_coll = batch.collection("foo");
    foo_coll.find...().remove();
    let mut bar_coll = batch.collection("bar");
    // Expensive multi-mutation op:
    for _ in 0 .. 10_000 {
        let doc = ...;
        bar_coll.insert(doc, None, false);
    }
    // At this point, we must say whether we commit or revert
    // these changes:
    batch.commit_changes()
})

Returns a list of the names of collections in the local store.

Returns a hash representing the current version of the given queries. When a document matching such queries gets mutated, the hash will change as well.

Please note that the hash depends on how queries are constructed, so you should make sure to always compare hashes generated with the same set of queries.

Returns a sequence of English words representing the current version of the given queries. When a document matching such queries gets mutated, the words will change as well.

Please note that the resulting sequence of words depends on how queries are constructed, so you should make sure to always compare hashes generated with the same set of queries.

Start all live query webhooks.

Start a live query webhooks by its id.

Register a new live query webhook

Generate a new API secret for live query webhook

Returns a TimeSeries with the provided name.

Return a DiskUsage to monitor the disk usage of the Store.

Register a handler to be called whenever a query’s results change in the local store.

The returned StoreObserver must be kept in scope for as long as the change handler should be called with new change events.

The given query may not modify any documents and must be a valid Ditto Query Language query.

If no on_error argument is provided, errors that are thrown in the provided change handler will be logged to the console.

Gets temporary access to the set of currently registered observers.

A (read) lock is held until the return value is dropped: this means that neither Self::register_observer() nor StoreObserver::cancel() can make progress until this read lock is released.

Executes the given query in the local store and returns the result.

Use placeholders to incorporate values from the optional query_args parameter into the query. The keys of the QueryArguments object must match the placeholders used within the query. You can not use placeholders in the FROM clause.

Limitations:

  • Supports SELECT * FROM <collection name> with optional WHERE <expression>
  • No transactions

Trait Implementations

Returns a copy of the value. Read more
Performs copy-assignment from source. Read more

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more
Immutably borrows from an owned value. Read more
Mutably borrows from an owned value. Read more
Applies the [Compat] adapter by value. Read more
Applies the [Compat] adapter by shared reference. Read more
Applies the [Compat] adapter by mutable reference. Read more

Returns the argument unchanged.

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Converts to T by calling Into<T>::into.
Tries to convert to T by calling TryInto<T>::try_into.
The resulting type after obtaining ownership.
Creates owned data from borrowed data, usually by cloning. Read more
Uses borrowed data to replace owned data, usually by cloning. Read more
The type returned in the event of a conversion error.
Performs the conversion.
The type returned in the event of a conversion error.
Performs the conversion.