1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29
//! Deletes entries matching the filter in the specified collection.
//!
//! # Examples
//!
//! ```
//! use mungos::{Mungos, doc}
//! use serde::{Serialize, Deserialize}
//!
//! #[derive(Debug, Serialize, Deserialize)]
//! struct Item {
//! field: String
//! }
//!
//! let db = Mungos::new("uri", "app name", timeout).await;
//! let collection = db.connection::<Item>("db name", "collection name");
//!
//! // deletes any items that match field: apple
//! collection.delete_many(doc! { "field": "apple" }).await.unwrap();
//! ```
//!
use crate::Collection;
use mongodb::{bson::Document, error::Result, results::DeleteResult};
impl<T> Collection<T> {
pub async fn delete_many(&self, filter: Document) -> Result<DeleteResult> {
self.collection.delete_many(filter, None).await
}
}