use super::Model;
use crate::{core::find::FindManyCursor, error::Error};
use mongodb::{
bson::{doc, Document},
options::*,
results::{DeleteResult, UpdateResult},
ClientSession,
};
use serde::{Deserialize, Serialize};
impl<D> Model<D>
where
D: Serialize + for<'a> Deserialize<'a> + Send + Sync + Unpin,
{
pub async fn find_all(
&self,
options: Option<FindOptions>,
session: Option<&mut ClientSession>,
) -> Result<FindManyCursor<D>, Error> {
self.find_many(doc! {}, options, session).await
}
pub async fn update_all(
&self,
update: Document,
options: Option<UpdateOptions>,
session: Option<&mut ClientSession>,
) -> Result<UpdateResult, Error> {
self.update_many(doc! {}, update, options, session).await
}
pub async fn delete_all(
&self,
options: Option<DeleteOptions>,
session: Option<&mut ClientSession>,
) -> Result<DeleteResult, Error> {
self.delete_many(doc! {}, options, session).await
}
}