Struct dittolive_ditto::store::collection::Collection
source · [−]pub struct Collection { /* private fields */ }
Implementations
sourceimpl Collection
impl Collection
pub fn name(&self) -> &str
sourcepub fn find_all(&self) -> PendingCursorOperation<'_>
pub fn find_all(&self) -> PendingCursorOperation<'_>
Generates a DittoPendingCursorOperation that can be used to find all documents in the collection at a point in time or you can chain a call to observe_local or subscribe if you want to get updates about documents in the collection over time. It can also be used to update, remove, or evict documents.
sourcepub fn find(&self, query: &str) -> PendingCursorOperation<'_>
pub fn find(&self, query: &str) -> PendingCursorOperation<'_>
Generates a DittoPendingCursorOperation with the provided query that can be used to find the documents matching the query at a point in time or you can chain a call to observe_local or subscribe if you want to get updates about documents matching the query as they occur. It can also be used to update, remove, or evict documents.
sourcepub fn find_with_args<V: Serialize, C: Borrow<V>>(
&self,
query: &str,
query_args: C
) -> PendingCursorOperation<'_>
pub fn find_with_args<V: Serialize, C: Borrow<V>>(
&self,
query: &str,
query_args: C
) -> PendingCursorOperation<'_>
Generates a DittoPendingCursorOperation with the provided query and query arguments that can be used to find the documents matching the query at a point in time or you can chain a call to observe_local or subscribe if you want to get updates about documents matching the query as they occur. It can also be used to update, remove, or evict documents.
This is the recommended function to use when performing queries on a
collection if you have any dynamic data included in the query string. It
allows you to provide a query string with placeholders, in the form of
$args.my_arg_name
, along with an accompanying dictionary of arguments,
in the form of { "my_arg_name": "some value" }
, and the placeholders
will be appropriately replaced by the matching provided arguments from
the dictionary. This includes handling things like wrapping strings in
quotation marks and arrays in square brackets, for example.
sourcepub fn find_by_id(
&self,
doc_id: impl Into<DocumentId>
) -> PendingIdSpecificOperation
pub fn find_by_id(
&self,
doc_id: impl Into<DocumentId>
) -> PendingIdSpecificOperation
Generates a DittoPendingIDSpecificOperation with the provided document ID that can be used to find the document at a point in time or you can chain a call to observe_local or subscribe if you want to get updates about the document over time. It can also be used to update, remove, or evict the document.
sourceimpl Collection
impl Collection
sourcepub fn upsert<V: Serialize, C: Borrow<V>>(
&self,
content: C
) -> Result<DocumentId, DittoError>
pub fn upsert<V: Serialize, C: Borrow<V>>(
&self,
content: C
) -> Result<DocumentId, DittoError>
Inserts a new document into the collection and returns its ID. If the document already exists, the provided document content will be merged with the existing document’s content.
sourcepub fn upsert_with_strategy<V: Serialize, C: Borrow<V>>(
&self,
content: C,
write_strategy: WriteStrategy
) -> Result<DocumentId, DittoError>
pub fn upsert_with_strategy<V: Serialize, C: Borrow<V>>(
&self,
content: C,
write_strategy: WriteStrategy
) -> Result<DocumentId, DittoError>
Inserts a new document into the collection and returns its ID. If the
document already exists, the behavior is determined by the provided
write_strategy
.
sourcepub fn new_attachment<P: AsRef<Path>>(
&self,
path: P,
metadata: HashMap<String, String>
) -> Result<DittoAttachment, DittoError>
pub fn new_attachment<P: AsRef<Path>>(
&self,
path: P,
metadata: HashMap<String, String>
) -> Result<DittoAttachment, DittoError>
Creates a new attachment, which can then be inserted into a document.
The file residing at the provided path will be copied into the Ditto’s store. The DittoAttachment object that is returned is what you can then use to insert an attachment into a document.
You can provide metadata about the attachment, which will be replicated to other peers alongside the file attachment.
Below is a snippet to show how you can use the new_attachment functionality to insert an attachment into a document.
sourcepub fn fetch_attachment<'a>(
&self,
attachment_token: DittoAttachmentToken,
on_fetch_event: impl Fn(DittoAttachmentFetchEvent) + Send + Sync + 'a
) -> Result<DittoAttachmentFetcher<'a>, DittoError>
pub fn fetch_attachment<'a>(
&self,
attachment_token: DittoAttachmentToken,
on_fetch_event: impl Fn(DittoAttachmentFetchEvent) + Send + Sync + 'a
) -> Result<DittoAttachmentFetcher<'a>, DittoError>
Fetch the attachment corresponding to the provided attachment token.
onchange
- A closure that will be called when the status of the request to fetch the attachment has changed. If the attachment is already available then this will be called almost immediately with a completed status value.
Trait Implementations
sourceimpl Clone for Collection
impl Clone for Collection
sourcefn clone(&self) -> Collection
fn clone(&self) -> Collection
Returns a copy of the value. Read more
1.0.0 · sourcefn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from source
. Read more
Auto Trait Implementations
impl RefUnwindSafe for Collection
impl Send for Collection
impl Sync for Collection
impl Unpin for Collection
impl UnwindSafe for Collection
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcepub fn borrow_mut(&mut self) -> &mut T
pub fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
impl<T> ManuallyDropMut for T
impl<T> ManuallyDropMut for T
type Ret = ManuallyDrop<T>
pub fn manually_drop_mut(&'__ mut self) -> &'__ mut ManuallyDrop<T>
impl<T> To for T where
T: ?Sized,
impl<T> To for T where
T: ?Sized,
sourceimpl<T> ToOwned for T where
T: Clone,
impl<T> ToOwned for T where
T: Clone,
type Owned = T
type Owned = T
The resulting type after obtaining ownership.
sourcepub fn to_owned(&self) -> T
pub fn to_owned(&self) -> T
Creates owned data from borrowed data, usually by cloning. Read more
sourcepub fn clone_into(&self, target: &mut T)
pub fn clone_into(&self, target: &mut T)
toowned_clone_into
)Uses borrowed data to replace owned data, usually by cloning. Read more