1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
use crate::Collection;
use mongodb::{
    bson::{doc, oid::ObjectId},
    error::Result,
};
use std::str::FromStr;

impl<T> Collection<T> {
    pub async fn delete_one(&self, id: &str) -> Result<String> {
        let filter = doc! { "_id": ObjectId::from_str(id).unwrap() };
        self.collection.delete_one(filter, None).await?;
        Ok(id.to_string())
    }
}