Struct dittolive_ditto::store::collection::pending_cursor_operation::PendingCursorOperation
source · [−]pub struct PendingCursorOperation<'order_by> { /* private fields */ }
Implementations
sourceimpl<'order_by> PendingCursorOperation<'order_by>
impl<'order_by> PendingCursorOperation<'order_by>
pub fn new(
ditto: Arc<BoxedDitto>,
collection_name: Box,
query: &str,
query_args: Option<Vec<u8>>
) -> Self
sourcepub fn observe<Handler>(
&self,
handler: Handler
) -> Result<LiveQuery, DittoError> where
Handler: EventHandler,
pub fn observe<Handler>(
&self,
handler: Handler
) -> Result<LiveQuery, DittoError> where
Handler: EventHandler,
Enables you to listen for changes that occur on a collection. The eventHandler closure will be called when local or remote changes are made to documents that match the query generated by the chain of operations that precedes the call to observe. The returned DittoLiveQuery object must be kept in scope for as long as you want the provided eventHandler to be called when an update occurs.
sourcepub fn exec(&self) -> Result<Vec<BoxedDocument>, DittoError>
pub fn exec(&self) -> Result<Vec<BoxedDocument>, DittoError>
Execute the query generated by the preceding function chaining and return the list of matching documents. This occurs immediately.
sourcepub fn subscribe(&self) -> Subscription
pub fn subscribe(&self) -> Subscription
Enables you to subscribe to changes that occur on a collection. Having a subscription acts as a signal to others that you are interested in receiving updates when local or remote changes are made to documents that match the query generated by the chain of operations that precedes the call to subscribe. The returned DittoSubscription object must be kept in scope for as long as you want to keep receiving updates.
sourcepub fn update<Updater>(
&self,
updater: Updater
) -> Result<BTreeMap<DocumentId, Vec<UpdateResult>>, DittoError> where
Updater: Fn(&mut [BoxedDocument]),
pub fn update<Updater>(
&self,
updater: Updater
) -> Result<BTreeMap<DocumentId, Vec<UpdateResult>>, DittoError> where
Updater: Fn(&mut [BoxedDocument]),
Update the document with the matching ID.
updater
- a Fn which will be called on all matching documents
Note that fetching the documents occurs in one transaction and then
applying updater
to all fetched documents occurs in a single,
second transaction.
sourcepub fn limit(&mut self, limit: i32) -> &mut Self
pub fn limit(&mut self, limit: i32) -> &mut Self
Limit the number of documents that get returned when querying a collection for matching documents.
sourcepub fn offset(&mut self, offset: u32) -> &mut Self
pub fn offset(&mut self, offset: u32) -> &mut Self
Offset the resulting set of matching documents. This is useful if you aren’t interested in the first N matching documents for one reason or another. For example, you might already have queried the collection and obtained the first 20 matching documents and so you might want to run the same query as you did previously but ignore the first 20 matching documents, and that is where you would use offset.
sourcepub fn remove(&self) -> Result<Vec<DocumentId>, DittoError>
pub fn remove(&self) -> Result<Vec<DocumentId>, DittoError>
Remove all documents that match the query generated by the preceding function chaining. Returns the IDs of all documents removed
sourcepub fn evict(&self) -> Result<Vec<DocumentId>, DittoError>
pub fn evict(&self) -> Result<Vec<DocumentId>, DittoError>
Evict all documents that match the query generated by the preceding function chaining.
sourcepub fn observe_local<Handler>(
&self,
handler: Handler
) -> Result<LiveQuery, DittoError> where
Handler: EventHandler,
pub fn observe_local<Handler>(
&self,
handler: Handler
) -> Result<LiveQuery, DittoError> where
Handler: EventHandler,
Enables you to listen for changes that occur on a collection. This won’t subscribe to receive changes made remotely by others and so it will only fire updates when a local change is made. If you want to receive remotely performed updates as well then use observe or call subscribe with the relevant query. The returned DittoLiveQuery object must be kept in scope for as long as you want the provided eventHandler to be called when an update occurs.
sourcepub fn sort(&mut self, sort_param: Vec<COrderByParam<'order_by>>) -> &mut Self
pub fn sort(&mut self, sort_param: Vec<COrderByParam<'order_by>>) -> &mut Self
Sort the documents that match the query provided in the preceding find-like function call.
Auto Trait Implementations
impl<'order_by> RefUnwindSafe for PendingCursorOperation<'order_by>
impl<'order_by> !Send for PendingCursorOperation<'order_by>
impl<'order_by> !Sync for PendingCursorOperation<'order_by>
impl<'order_by> Unpin for PendingCursorOperation<'order_by>
impl<'order_by> UnwindSafe for PendingCursorOperation<'order_by>
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