use mongodb::{bson::Bson, sync::Database};
use serde::{de::DeserializeOwned, Serialize};
use crate::error::Result;
#[cfg_attr(feature = "tokio-runtime", async_trait::async_trait)]
pub trait SchemaBefore: DeserializeOwned + Serialize + Send + Into<Bson> + Clone {
#[cfg(feature = "sync")]
fn before_create(&mut self, _db: &Database) -> Result<()> {
Ok(())
}
#[cfg(feature = "tokio-runtime")]
async fn before_create(&mut self, _db: &Database) -> Result<()> {
Ok(())
}
#[cfg(feature = "sync")]
fn before_update(&mut self, _db: &Database) -> Result<()> {
Ok(())
}
#[cfg(feature = "tokio-runtime")]
async fn before_update(&mut self, _db: &Database) -> Result<()> {
Ok(())
}
}