pub trait Hooks {
    // Provided methods
    fn pre_create<'life0, 'life1, 'async_trait>(
        &'life0 self,
        _client: &'life1 Client
    ) -> Pin<Box<dyn Future<Output = ()> + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait { ... }
    fn post_create<'life0, 'life1, 'async_trait>(
        &'life0 self,
        _client: &'life1 Client
    ) -> Pin<Box<dyn Future<Output = ()> + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait { ... }
    fn pre_update<'life0, 'life1, 'async_trait>(
        &'life0 self,
        _client: &'life1 Client
    ) -> Pin<Box<dyn Future<Output = ()> + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait { ... }
    fn post_update<'life0, 'life1, 'async_trait>(
        &'life0 self,
        _client: &'life1 Client
    ) -> Pin<Box<dyn Future<Output = ()> + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait { ... }
    fn pre_delete<'life0, 'life1, 'async_trait>(
        &'life0 self,
        _client: &'life1 Client
    ) -> Pin<Box<dyn Future<Output = ()> + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait { ... }
    fn post_delete<'life0, 'life1, 'async_trait>(
        &'life0 self,
        _client: &'life1 Client
    ) -> Pin<Box<dyn Future<Output = ()> + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait { ... }
}
Expand description

Hooks methods.

Provided Methods§

source

fn pre_create<'life0, 'life1, 'async_trait>( &'life0 self, _client: &'life1 Client ) -> Pin<Box<dyn Future<Output = ()> + 'async_trait>>where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Called before a new document is created in the database.

Example:
#[Model(
    is_use_hooks = true
)]
#[derive(Serialize, Deserialize, Default, Debug)]
pub struct ModelName {
    Add your fields ...
}

impl Hooks for ModelName {
    fn pre_create(&self) {
        Some code ...
   }
}
source

fn post_create<'life0, 'life1, 'async_trait>( &'life0 self, _client: &'life1 Client ) -> Pin<Box<dyn Future<Output = ()> + 'async_trait>>where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Called after a new document has been created in the database.

#[Model(
    is_use_hooks = true
)]
#[derive(Serialize, Deserialize, Default, Debug)]
pub struct ModelName {
    Add your fields ...
}

impl Hooks for ModelName {
    fn post_create(&self) {
        Some code ...
   }
}
source

fn pre_update<'life0, 'life1, 'async_trait>( &'life0 self, _client: &'life1 Client ) -> Pin<Box<dyn Future<Output = ()> + 'async_trait>>where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Called before updating an existing document in the database.

#[Model(
    is_use_hooks = true
)]
#[derive(Serialize, Deserialize, Default, Debug)]
pub struct ModelName {
    Add your fields ...
}

impl Hooks for ModelName {
    fn pre_update(&self) {
        Some code ...
   }
}
source

fn post_update<'life0, 'life1, 'async_trait>( &'life0 self, _client: &'life1 Client ) -> Pin<Box<dyn Future<Output = ()> + 'async_trait>>where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Called after an existing document in the database is updated.

#[Model(
    is_use_hooks = true
)]
#[derive(Serialize, Deserialize, Default, Debug)]
pub struct ModelName {
    Add your fields ...
}

impl Hooks for ModelName {
    fn post_update(&self) {
        Some code ...
   }
}
source

fn pre_delete<'life0, 'life1, 'async_trait>( &'life0 self, _client: &'life1 Client ) -> Pin<Box<dyn Future<Output = ()> + 'async_trait>>where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Called before deleting an existing document in the database.

#[Model(
    is_use_hooks = true
)]
#[derive(Serialize, Deserialize, Default, Debug)]
pub struct ModelName {
    Add your fields ...
}

impl Hooks for ModelName {
    fn pre_delete(&self) {
        Some code ...
   }
}
source

fn post_delete<'life0, 'life1, 'async_trait>( &'life0 self, _client: &'life1 Client ) -> Pin<Box<dyn Future<Output = ()> + 'async_trait>>where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Called after an existing document in the database has been deleted.

#[Model(
    is_use_hooks = true
)]
#[derive(Serialize, Deserialize, Default, Debug)]
pub struct ModelName {
    Add your fields ...
}

impl Hooks for ModelName {
    fn post_delete(&self) {
        Some code ...
   }
}

Implementors§