pub struct Delete<C: Collection> { /* private fields */ }
Expand description
A querier to delete documents from a MongoDB collection.
Examples
Delete all documents from a collection.
#[derive(Bson, Mongo)]
#[mongo(collection="users", field, filter, update)]
pub struct User {
name: String,
}
let client = mongod::Client::new();
let deleted = mongod::query::Delete::<User>::new()
.query(&client)
.await
.unwrap();
println!("delete {} documents", deleted);
Implementations
sourceimpl<C: Collection> Delete<C>
impl<C: Collection> Delete<C>
sourcepub fn collation(self, collation: Collation) -> Self
pub fn collation(self, collation: Collation) -> Self
The collation to use for the operation.
Collation allows users to specify language-specific rules for string comparison, such as rules for lettercase and accent marks.
sourcepub fn filter<F>(self, filter: F) -> Result<Self, Error> where
C: AsFilter<F>,
F: Filter,
pub fn filter<F>(self, filter: F) -> Result<Self, Error> where
C: AsFilter<F>,
F: Filter,
The filter to use for the operation.
Errors
This method errors if the filter could not be converted into a BSON Document
.
sourcepub fn hint(self, hint: Hint) -> Self
pub fn hint(self, hint: Hint) -> Self
A document or string that specifies the index to use to support the query predicate.
sourcepub fn many(self, many: bool) -> Self
pub fn many(self, many: bool) -> Self
Enable delete many for this operation.
Removes all documents that match the filter from a collection.
sourcepub fn write_concern(self, write_concern: WriteConcern) -> Self
pub fn write_concern(self, write_concern: WriteConcern) -> Self
The write concern for the operation.
Trait Implementations
sourceimpl<C: Clone + Collection> Clone for Delete<C>
impl<C: Clone + Collection> Clone for Delete<C>
Auto Trait Implementations
impl<C> RefUnwindSafe for Delete<C> where
C: RefUnwindSafe,
impl<C> Send for Delete<C> where
C: Send,
impl<C> Sync for Delete<C> where
C: Sync,
impl<C> Unpin for Delete<C> where
C: Unpin,
impl<C> UnwindSafe for Delete<C> where
C: UnwindSafe,
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
sourceimpl<T> Instrument for T
impl<T> Instrument for T
sourcefn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
sourcefn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
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
impl<V, T> VZip<V> for T where
V: MultiLane<T>,
impl<V, T> VZip<V> for T where
V: MultiLane<T>,
pub fn vzip(self) -> V
sourceimpl<T> WithSubscriber for T
impl<T> WithSubscriber for T
sourcefn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> where
S: Into<Dispatch>,
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
sourcefn with_current_subscriber(self) -> WithDispatch<Self>
fn with_current_subscriber(self) -> WithDispatch<Self>
Attaches the current default Subscriber
to this type, returning a
WithDispatch
wrapper. Read more