Skip to main content

Seeder

Trait Seeder 

Source
pub trait Seeder: Send + Sync {
    // Required method
    fn run<'life0, 'life1, 'async_trait>(
        &'life0 self,
        db: &'life1 DatabasePool,
    ) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send + 'async_trait>>
       where 'life0: 'async_trait,
             'life1: 'async_trait,
             Self: 'async_trait;
}
Expand description

Trait yang diimplementasikan oleh setiap Seeder class

§Contoh:

ⓘ
pub struct UserSeeder;

#[async_trait::async_trait]
impl Seeder for UserSeeder {
    async fn run(&self, db: &DatabasePool) -> Result<(), sqlx::Error> {
        User::factory().count(50).create(db).await?;
        Ok(())
    }
}

Required Methods§

Source

fn run<'life0, 'life1, 'async_trait>( &'life0 self, db: &'life1 DatabasePool, ) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send + 'async_trait>>
where 'life0: 'async_trait, 'life1: 'async_trait, Self: 'async_trait,

Jalankan proses pengisian data dummy atau awal ke database

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§