pub struct FactoryBuilder<M, F> { /* private fields */ }Expand description
FactoryBuilder — Mengelola modifier state, perulangan, dan eksekusi penyimpanan ke database.
Implementations§
Source§impl<M, F> FactoryBuilder<M, F>
impl<M, F> FactoryBuilder<M, F>
pub fn new(factory: F, count: usize) -> FactoryBuilder<M, F>
Sourcepub fn count(self, count: usize) -> FactoryBuilder<M, F>
pub fn count(self, count: usize) -> FactoryBuilder<M, F>
Mengubah jumlah record yang ingin dihasilkan
Sourcepub fn state<S>(self, modifier: S) -> FactoryBuilder<M, F>
pub fn state<S>(self, modifier: S) -> FactoryBuilder<M, F>
Menambahkan modifikasi state (misal: role = “admin”, is_active = true)
pub fn add_state<S>(&mut self, modifier: S)
Sourcepub fn make_one(&self) -> M
pub fn make_one(&self) -> M
Menghasilkan 1 objek model in-memory dengan menerapkan seluruh state modifier
Sourcepub fn make(&self) -> Vec<M>
pub fn make(&self) -> Vec<M>
Menghasilkan kumpulan objek model in-memory (tanpa menyentuh database)
Sourcepub async fn create_one(&self, db: &DatabasePool) -> Result<M, AppError>
pub async fn create_one(&self, db: &DatabasePool) -> Result<M, AppError>
Menyimpan 1 record ke database dan mengembalikan model yang sudah memiliki ID
Auto Trait Implementations§
impl<M, F> !RefUnwindSafe for FactoryBuilder<M, F>
impl<M, F> !UnwindSafe for FactoryBuilder<M, F>
impl<M, F> Forget for FactoryBuilder<M, F>
impl<M, F> Freeze for FactoryBuilder<M, F>
impl<M, F> Move for FactoryBuilder<M, F>
impl<M, F> Send for FactoryBuilder<M, F>
impl<M, F> Sync for FactoryBuilder<M, F>
impl<M, F> Unpin for FactoryBuilder<M, F>
impl<M, F> UnsafeUnpin for FactoryBuilder<M, F>where
F: UnsafeUnpin,
Vec<Box<dyn Fn(&mut M) + Send + Sync>>: UnsafeUnpin,
PhantomData<M>: UnsafeUnpin,
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more