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

A reference to a collection in a Store

Implementations§

source§

impl Collection

source

pub fn name(&self) -> &str

The name of the collection.

source

pub fn find_all(&self) -> PendingCursorOperation<'_>

Generates a PendingCursorOperation that can be used to find all documents in the collection at a point in time or you can chain a call to PendingCursorOperation::observe_local or PendingCursorOperation::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.

source

pub fn find(&self, query: &str) -> PendingCursorOperation<'_>

Generates a PendingCursorOperation 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 PendingCursorOperation::observe_local or PendingCursorOperation::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.

source

pub fn find_with_args<V: Serialize, C: Borrow<V>>( &self, query: &str, query_args: C ) -> PendingCursorOperation<'_>

Generates a PendingCursorOperation 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 PendingCursorOperation::observe_local or PendingCursorOperation::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.

source

pub fn find_by_id( &self, doc_id: impl Into<DocumentId> ) -> PendingIdSpecificOperation

Generates a PendingIdSpecificOperation 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 PendingIdSpecificOperation::observe_local or PendingIdSpecificOperation::subscribe if you want to get updates about the document over time. It can also be used to update, remove, or evict the document.

source§

impl Collection

source

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.

source

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.

source

pub fn new_attachment<P: AsRef<Path>>( &self, filepath: P, metadata: HashMap<String, String> ) -> Result<DittoAttachment, DittoError>

👎Deprecated: Use ditto.store().new_attachment() instead

Creates a new attachment, which can then be inserted into a document.

This API is deprecated. Use ditto.store().new_attachment() instead.

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.

source

pub fn fetch_attachment<'a>( &self, attachment_token: DittoAttachmentToken, on_fetch_event: impl 'a + Send + Sync + Fn(DittoAttachmentFetchEvent) ) -> Result<DittoAttachmentFetcher<'a, V1>, DittoError>

👎Deprecated: Use ditto.store().fetch_attachment() instead

Fetch the attachment corresponding to the provided attachment token.

This API is deprecated. Use ditto.store().fetch_attachment() instead.

  • on_fetch_event: 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§

source§

impl Clone for Collection

source§

fn clone(&self) -> Collection

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

impl Debug for Collection

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

Blanket Implementations§

source§

impl<T> Any for T
where T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for T
where T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
§

impl<T> CompatExt for T

§

fn compat(self) -> Compat<T>

Applies the [Compat] adapter by value. Read more
§

fn compat_ref(&self) -> Compat<&T>

Applies the [Compat] adapter by shared reference. Read more
§

fn compat_mut(&mut self) -> Compat<&mut T>

Applies the [Compat] adapter by mutable reference. Read more
§

impl<T> FitForCBox for T

§

type CBoxWrapped = Box_<T>

source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<T> Instrument for T

§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided [Span], returning an Instrumented wrapper. Read more
§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
source§

impl<T, U> Into<U> for T
where U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

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

§

impl<T> ManuallyDropMut for T

§

type Ret = ManuallyDrop<T>

§

fn manually_drop_mut<'__>(&'__ mut self) -> &'__ mut ManuallyDrop<T>

§

impl<T> To for T
where T: ?Sized,

§

fn to<T>(self) -> T
where Self: Into<T>,

Converts to T by calling Into<T>::into.
§

fn try_to<T>(self) -> Result<T, Self::Error>
where Self: TryInto<T>,

Tries to convert to T by calling TryInto<T>::try_into.
source§

impl<T> ToOwned for T
where T: Clone,

§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

§

fn vzip(self) -> V

§

impl<T> WithSubscriber for T

§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a [WithDispatch] wrapper. Read more
§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a [WithDispatch] wrapper. Read more
§

impl<F> ZeroSizedElseWrathOfTheGඞds for F