Struct dittolive_ditto::store::Store
source · [−]pub struct Store { /* private fields */ }
Expand description
Store
provides access to Collection
s and a
write transaction API.
Implementations
sourceimpl Store
impl Store
pub fn new(ditto: Arc<BoxedDitto>) -> Self
sourcepub fn collection(&self, collection_name: &str) -> Result<Collection, DittoError>
pub fn collection(&self, collection_name: &str) -> Result<Collection, DittoError>
Returns a Collection
with the provided name.
sourcepub fn collections(&self) -> PendingCollectionsOperation<'_>
pub fn collections(&self) -> PendingCollectionsOperation<'_>
Returns an object that lets you fetch or observe the collections in the store.
sourcepub fn with_batched_write<F>(
&self,
f: F
) -> Result<Vec<WriteTransactionResult>, DittoError>where
for<'batch> F: FnOnce(ScopedStore<'batch>) -> Action<'batch>,
pub fn with_batched_write<F>(
&self,
f: F
) -> Result<Vec<WriteTransactionResult>, DittoError>where
for<'batch> F: FnOnce(ScopedStore<'batch>) -> Action<'batch>,
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()
})
sourcepub fn collection_names(&self) -> Result<Vec<String>, DittoError>
pub fn collection_names(&self) -> Result<Vec<String>, DittoError>
Returns a list of the names of collections in the local store.
sourcepub fn queries_hash(&self, live_queries: &[LiveQuery]) -> Result<u64, DittoError>
pub fn queries_hash(&self, live_queries: &[LiveQuery]) -> Result<u64, DittoError>
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.
sourcepub fn queries_hash_mnemonic(
&self,
live_queries: &[LiveQuery]
) -> Result<String, DittoError>
pub fn queries_hash_mnemonic(
&self,
live_queries: &[LiveQuery]
) -> Result<String, DittoError>
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.
sourcepub fn start_all_live_query_webhooks(&self) -> Result<(), DittoError>
pub fn start_all_live_query_webhooks(&self) -> Result<(), DittoError>
Start all live query webhooks.
sourcepub fn start_live_query_webhook_by_id(
&self,
doc_id: DocumentId
) -> Result<(), DittoError>
pub fn start_live_query_webhook_by_id(
&self,
doc_id: DocumentId
) -> Result<(), DittoError>
Start a live query webhooks by its id.
sourcepub fn register_live_query_webhook(
&self,
collection_name: &str,
query: &str,
url: &str
) -> Result<DocumentId, DittoError>
pub fn register_live_query_webhook(
&self,
collection_name: &str,
query: &str,
url: &str
) -> Result<DocumentId, DittoError>
Register a new live query webhook
sourcepub fn live_query_webhook_generate_new_api_secret(
&self
) -> Result<(), DittoError>
pub fn live_query_webhook_generate_new_api_secret(
&self
) -> Result<(), DittoError>
Generate a new API secret for live query webhook
sourcepub fn timeseries(&self, ts_name: &str) -> Result<TimeSeries, DittoError>
pub fn timeseries(&self, ts_name: &str) -> Result<TimeSeries, DittoError>
Returns a TimeSeries
with the provided name.
sourcepub fn disk_usage(&self) -> &DiskUsage
pub fn disk_usage(&self) -> &DiskUsage
Trait Implementations
Auto Trait Implementations
impl RefUnwindSafe for Store
impl Send for Store
impl Sync for Store
impl Unpin for Store
impl UnwindSafe for Store
Blanket Implementations
sourceimpl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
impl<T> CompatExt for T
impl<T> CompatExt for T
fn compat_ref(&self) -> Compat<&T>
fn compat_ref(&self) -> Compat<&T>
Compat
] adapter by shared reference. Read morefn compat_mut(&mut self) -> Compat<&mut T>
fn compat_mut(&mut self) -> Compat<&mut T>
Compat
] adapter by mutable reference. Read more