pub trait Model:
Sized
+ Send
+ Sync
+ for<'r> FromRow<'r, AnyRow>
+ Unpin
+ DeserializeOwned {
const TABLE: &'static str;
const HAS_SOFT_DELETES: bool = false;
Show 33 methods
// Required methods
fn find<'life0, 'async_trait>(
pool: &'life0 DatabasePool,
id: i64,
) -> Pin<Box<dyn Future<Output = Result<Self, Error>> + Send + 'async_trait>>
where 'life0: 'async_trait,
Self: 'async_trait;
fn all<'life0, 'async_trait>(
pool: &'life0 DatabasePool,
) -> Pin<Box<dyn Future<Output = Result<Vec<Self>, Error>> + Send + 'async_trait>>
where 'life0: 'async_trait,
Self: 'async_trait;
fn save<'life0, 'life1, 'async_trait>(
&'life0 self,
pool: &'life1 DatabasePool,
) -> Pin<Box<dyn Future<Output = Result<i64, Error>> + Send + 'async_trait>>
where 'life0: 'async_trait,
'life1: 'async_trait,
Self: 'async_trait;
fn delete<'life0, 'async_trait>(
pool: &'life0 DatabasePool,
id: i64,
) -> Pin<Box<dyn Future<Output = Result<bool, Error>> + Send + 'async_trait>>
where 'life0: 'async_trait;
// Provided methods
fn primary_key(&self) -> i64 { ... }
fn query(pool: &DatabasePool) -> QueryBuilder<'_, Self> { ... }
fn where_eq<'a, V>(
pool: &'a DatabasePool,
column: &'a str,
value: V,
) -> QueryBuilder<'a, Self>
where V: 'a + Send + Encode<'a, Any> + Type<Any> { ... }
fn where_like<'a, V>(
pool: &'a DatabasePool,
column: &'a str,
pattern: V,
) -> QueryBuilder<'a, Self>
where V: 'a + Send + Encode<'a, Any> + Type<Any> { ... }
fn where_null<'a>(
pool: &'a DatabasePool,
column: &'a str,
) -> QueryBuilder<'a, Self> { ... }
fn where_not_null<'a>(
pool: &'a DatabasePool,
column: &'a str,
) -> QueryBuilder<'a, Self> { ... }
fn latest<'a>(pool: &'a DatabasePool) -> QueryBuilder<'a, Self> { ... }
fn oldest<'a>(pool: &'a DatabasePool) -> QueryBuilder<'a, Self> { ... }
fn where_has<'a>(
pool: &'a DatabasePool,
relation_table: &'a str,
foreign_key: &'a str,
local_key: &'a str,
) -> QueryBuilder<'a, Self> { ... }
fn where_doesnt_have<'a>(
pool: &'a DatabasePool,
relation_table: &'a str,
foreign_key: &'a str,
local_key: &'a str,
) -> QueryBuilder<'a, Self> { ... }
fn count<'life0, 'async_trait>(
pool: &'life0 DatabasePool,
) -> Pin<Box<dyn Future<Output = Result<i64, Error>> + Send + 'async_trait>>
where 'life0: 'async_trait,
Self: 'async_trait { ... }
fn paginate<'life0, 'async_trait>(
pool: &'life0 DatabasePool,
page: usize,
per_page: usize,
) -> Pin<Box<dyn Future<Output = Result<LengthAwarePaginator<Self>, Error>> + Send + 'async_trait>>
where 'life0: 'async_trait,
Self: 'async_trait { ... }
fn destroy<'life0, 'async_trait>(
pool: &'life0 DatabasePool,
id: i64,
) -> Pin<Box<dyn Future<Output = Result<bool, Error>> + Send + 'async_trait>>
where 'life0: 'async_trait,
Self: 'async_trait { ... }
fn exists<'life0, 'async_trait>(
pool: &'life0 DatabasePool,
) -> Pin<Box<dyn Future<Output = Result<bool, Error>> + Send + 'async_trait>>
where 'life0: 'async_trait,
Self: 'async_trait { ... }
fn find_or_fail<'life0, 'async_trait>(
pool: &'life0 DatabasePool,
id: i64,
) -> Pin<Box<dyn Future<Output = Result<Self, Error>> + Send + 'async_trait>>
where 'life0: 'async_trait,
Self: 'async_trait { ... }
fn first_or_create<'life0, 'async_trait, K, V>(
pool: &'life0 DatabasePool,
attributes: impl IntoIterator<Item = (K, V)> + Send + 'async_trait,
values: impl IntoIterator<Item = (K, V)> + Send + 'async_trait,
) -> Pin<Box<dyn Future<Output = Result<Self, Error>> + Send + 'async_trait>>
where 'life0: 'async_trait,
K: AsRef<str> + 'async_trait,
V: ToString + 'async_trait,
Self: 'async_trait { ... }
fn update_or_create<'life0, 'async_trait, K, V>(
pool: &'life0 DatabasePool,
attributes: impl IntoIterator<Item = (K, V)> + Send + 'async_trait,
values: impl IntoIterator<Item = (K, V)> + Send + 'async_trait,
) -> Pin<Box<dyn Future<Output = Result<Self, Error>> + Send + 'async_trait>>
where 'life0: 'async_trait,
K: AsRef<str> + 'async_trait,
V: ToString + 'async_trait,
Self: 'async_trait { ... }
fn find_many<'life0, 'life1, 'async_trait>(
pool: &'life0 DatabasePool,
ids: &'life1 [i64],
) -> Pin<Box<dyn Future<Output = Result<Vec<Self>, Error>> + Send + 'async_trait>>
where 'life0: 'async_trait,
'life1: 'async_trait,
Self: 'async_trait { ... }
fn restore<'life0, 'async_trait>(
pool: &'life0 DatabasePool,
id: i64,
) -> Pin<Box<dyn Future<Output = Result<bool, Error>> + Send + 'async_trait>>
where 'life0: 'async_trait,
Self: 'async_trait { ... }
fn force_delete<'life0, 'async_trait>(
pool: &'life0 DatabasePool,
id: i64,
) -> Pin<Box<dyn Future<Output = Result<bool, Error>> + Send + 'async_trait>>
where 'life0: 'async_trait,
Self: 'async_trait { ... }
fn truncate<'life0, 'async_trait>(
pool: &'life0 DatabasePool,
) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send + 'async_trait>>
where 'life0: 'async_trait,
Self: 'async_trait { ... }
fn with_trashed<'a>(pool: &'a DatabasePool) -> QueryBuilder<'a, Self> { ... }
fn only_trashed<'a>(pool: &'a DatabasePool) -> QueryBuilder<'a, Self> { ... }
fn create<'life0, 'async_trait, K, V>(
pool: &'life0 DatabasePool,
data: impl IntoIterator<Item = (K, V)> + Send + 'async_trait,
) -> Pin<Box<dyn Future<Output = Result<Self, Error>> + Send + 'async_trait>>
where 'life0: 'async_trait,
K: AsRef<str> + 'async_trait,
V: ToString + 'async_trait,
Self: 'async_trait { ... }
fn has_many<'life0, 'life1, 'async_trait, R>(
pool: &'life0 DatabasePool,
foreign_key: &'life1 str,
local_id: i64,
) -> Pin<Box<dyn Future<Output = Result<Vec<R>, Error>> + Send + 'async_trait>>
where 'life0: 'async_trait,
'life1: 'async_trait,
R: Model + 'async_trait { ... }
fn has_one<'life0, 'life1, 'async_trait, R>(
pool: &'life0 DatabasePool,
foreign_key: &'life1 str,
local_id: i64,
) -> Pin<Box<dyn Future<Output = Result<R, Error>> + Send + 'async_trait>>
where 'life0: 'async_trait,
'life1: 'async_trait,
R: Model + 'async_trait { ... }
fn belongs_to<'life0, 'async_trait, R>(
pool: &'life0 DatabasePool,
foreign_key_id: i64,
) -> Pin<Box<dyn Future<Output = Result<R, Error>> + Send + 'async_trait>>
where 'life0: 'async_trait,
R: Model + 'async_trait { ... }
fn belongs_to_many<'life0, 'life1, 'life2, 'life3, 'async_trait, R>(
pool: &'life0 DatabasePool,
pivot_table: &'life1 str,
foreign_key: &'life2 str,
related_key: &'life3 str,
local_id: i64,
) -> Pin<Box<dyn Future<Output = Result<Vec<R>, Error>> + Send + 'async_trait>>
where 'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
'life3: 'async_trait,
R: Model + 'async_trait { ... }
fn eager_load<'life0, 'life1, 'life2, 'async_trait>(
_relation: &'life0 str,
_items: &'life1 mut [Self],
_pool: &'life2 DatabasePool,
) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send + 'async_trait>>
where 'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
Self: 'async_trait { ... }
}Expand description
Required Associated Constants§
Provided Associated Constants§
Sourceconst HAS_SOFT_DELETES: bool = false
const HAS_SOFT_DELETES: bool = false
Apakah model ini mengaktifkan Soft Deletes (kolom deleted_at)
Required Methods§
Sourcefn find<'life0, 'async_trait>(
pool: &'life0 DatabasePool,
id: i64,
) -> Pin<Box<dyn Future<Output = Result<Self, Error>> + Send + 'async_trait>>where
'life0: 'async_trait,
Self: 'async_trait,
fn find<'life0, 'async_trait>(
pool: &'life0 DatabasePool,
id: i64,
) -> Pin<Box<dyn Future<Output = Result<Self, Error>> + Send + 'async_trait>>where
'life0: 'async_trait,
Self: 'async_trait,
Ambil satu record berdasarkan primary key. Mengembalikan error jika tidak ditemukan.
Sourcefn all<'life0, 'async_trait>(
pool: &'life0 DatabasePool,
) -> Pin<Box<dyn Future<Output = Result<Vec<Self>, Error>> + Send + 'async_trait>>where
'life0: 'async_trait,
Self: 'async_trait,
fn all<'life0, 'async_trait>(
pool: &'life0 DatabasePool,
) -> Pin<Box<dyn Future<Output = Result<Vec<Self>, Error>> + Send + 'async_trait>>where
'life0: 'async_trait,
Self: 'async_trait,
Ambil semua record yang aktif (bukan soft-deleted).
Sourcefn save<'life0, 'life1, 'async_trait>(
&'life0 self,
pool: &'life1 DatabasePool,
) -> Pin<Box<dyn Future<Output = Result<i64, Error>> + Send + 'async_trait>>where
'life0: 'async_trait,
'life1: 'async_trait,
Self: 'async_trait,
fn save<'life0, 'life1, 'async_trait>(
&'life0 self,
pool: &'life1 DatabasePool,
) -> Pin<Box<dyn Future<Output = Result<i64, Error>> + Send + 'async_trait>>where
'life0: 'async_trait,
'life1: 'async_trait,
Self: 'async_trait,
Simpan record ini ke database.
Mengembalikan last_insert_rowid jika sukses.
Provided Methods§
Sourcefn primary_key(&self) -> i64
fn primary_key(&self) -> i64
Nilai primary key record ini
Sourcefn query(pool: &DatabasePool) -> QueryBuilder<'_, Self>
fn query(pool: &DatabasePool) -> QueryBuilder<'_, Self>
Inisialisasi QueryBuilder untuk model ini.
Sourcefn where_eq<'a, V>(
pool: &'a DatabasePool,
column: &'a str,
value: V,
) -> QueryBuilder<'a, Self>
fn where_eq<'a, V>( pool: &'a DatabasePool, column: &'a str, value: V, ) -> QueryBuilder<'a, Self>
Shortcut query WHERE column = value
Sourcefn where_like<'a, V>(
pool: &'a DatabasePool,
column: &'a str,
pattern: V,
) -> QueryBuilder<'a, Self>
fn where_like<'a, V>( pool: &'a DatabasePool, column: &'a str, pattern: V, ) -> QueryBuilder<'a, Self>
Shortcut query WHERE column LIKE pattern
Sourcefn where_null<'a>(
pool: &'a DatabasePool,
column: &'a str,
) -> QueryBuilder<'a, Self>
fn where_null<'a>( pool: &'a DatabasePool, column: &'a str, ) -> QueryBuilder<'a, Self>
Shortcut query WHERE column IS NULL
Sourcefn where_not_null<'a>(
pool: &'a DatabasePool,
column: &'a str,
) -> QueryBuilder<'a, Self>
fn where_not_null<'a>( pool: &'a DatabasePool, column: &'a str, ) -> QueryBuilder<'a, Self>
Shortcut query WHERE column IS NOT NULL
Sourcefn latest<'a>(pool: &'a DatabasePool) -> QueryBuilder<'a, Self>
fn latest<'a>(pool: &'a DatabasePool) -> QueryBuilder<'a, Self>
Shortcut ORDER BY created_at DESC
Sourcefn oldest<'a>(pool: &'a DatabasePool) -> QueryBuilder<'a, Self>
fn oldest<'a>(pool: &'a DatabasePool) -> QueryBuilder<'a, Self>
Shortcut ORDER BY created_at ASC
Sourcefn where_has<'a>(
pool: &'a DatabasePool,
relation_table: &'a str,
foreign_key: &'a str,
local_key: &'a str,
) -> QueryBuilder<'a, Self>
fn where_has<'a>( pool: &'a DatabasePool, relation_table: &'a str, foreign_key: &'a str, local_key: &'a str, ) -> QueryBuilder<'a, Self>
Shortcut query WHERE EXISTS relasi (Laravel: Model::whereHas)
Sourcefn where_doesnt_have<'a>(
pool: &'a DatabasePool,
relation_table: &'a str,
foreign_key: &'a str,
local_key: &'a str,
) -> QueryBuilder<'a, Self>
fn where_doesnt_have<'a>( pool: &'a DatabasePool, relation_table: &'a str, foreign_key: &'a str, local_key: &'a str, ) -> QueryBuilder<'a, Self>
Shortcut query WHERE NOT EXISTS relasi (Laravel: Model::whereDoesntHave)
Sourcefn count<'life0, 'async_trait>(
pool: &'life0 DatabasePool,
) -> Pin<Box<dyn Future<Output = Result<i64, Error>> + Send + 'async_trait>>where
'life0: 'async_trait,
Self: 'async_trait,
fn count<'life0, 'async_trait>(
pool: &'life0 DatabasePool,
) -> Pin<Box<dyn Future<Output = Result<i64, Error>> + Send + 'async_trait>>where
'life0: 'async_trait,
Self: 'async_trait,
Hitung total record aktif di database
Sourcefn paginate<'life0, 'async_trait>(
pool: &'life0 DatabasePool,
page: usize,
per_page: usize,
) -> Pin<Box<dyn Future<Output = Result<LengthAwarePaginator<Self>, Error>> + Send + 'async_trait>>where
'life0: 'async_trait,
Self: 'async_trait,
fn paginate<'life0, 'async_trait>(
pool: &'life0 DatabasePool,
page: usize,
per_page: usize,
) -> Pin<Box<dyn Future<Output = Result<LengthAwarePaginator<Self>, Error>> + Send + 'async_trait>>where
'life0: 'async_trait,
Self: 'async_trait,
Ambil data terpaginasi langsung dari Model
Sourcefn destroy<'life0, 'async_trait>(
pool: &'life0 DatabasePool,
id: i64,
) -> Pin<Box<dyn Future<Output = Result<bool, Error>> + Send + 'async_trait>>where
'life0: 'async_trait,
Self: 'async_trait,
fn destroy<'life0, 'async_trait>(
pool: &'life0 DatabasePool,
id: i64,
) -> Pin<Box<dyn Future<Output = Result<bool, Error>> + Send + 'async_trait>>where
'life0: 'async_trait,
Self: 'async_trait,
Hapus record berdasarkan ID (alias delete ala Laravel Destroy)
Sourcefn exists<'life0, 'async_trait>(
pool: &'life0 DatabasePool,
) -> Pin<Box<dyn Future<Output = Result<bool, Error>> + Send + 'async_trait>>where
'life0: 'async_trait,
Self: 'async_trait,
fn exists<'life0, 'async_trait>(
pool: &'life0 DatabasePool,
) -> Pin<Box<dyn Future<Output = Result<bool, Error>> + Send + 'async_trait>>where
'life0: 'async_trait,
Self: 'async_trait,
Cek apakah terdapat record yang memenuhi kriteria
Sourcefn find_or_fail<'life0, 'async_trait>(
pool: &'life0 DatabasePool,
id: i64,
) -> Pin<Box<dyn Future<Output = Result<Self, Error>> + Send + 'async_trait>>where
'life0: 'async_trait,
Self: 'async_trait,
fn find_or_fail<'life0, 'async_trait>(
pool: &'life0 DatabasePool,
id: i64,
) -> Pin<Box<dyn Future<Output = Result<Self, Error>> + Send + 'async_trait>>where
'life0: 'async_trait,
Self: 'async_trait,
Ambil record berdasarkan ID atau return Error.
Sourcefn first_or_create<'life0, 'async_trait, K, V>(
pool: &'life0 DatabasePool,
attributes: impl IntoIterator<Item = (K, V)> + Send + 'async_trait,
values: impl IntoIterator<Item = (K, V)> + Send + 'async_trait,
) -> Pin<Box<dyn Future<Output = Result<Self, Error>> + Send + 'async_trait>>
fn first_or_create<'life0, 'async_trait, K, V>( pool: &'life0 DatabasePool, attributes: impl IntoIterator<Item = (K, V)> + Send + 'async_trait, values: impl IntoIterator<Item = (K, V)> + Send + 'async_trait, ) -> Pin<Box<dyn Future<Output = Result<Self, Error>> + Send + 'async_trait>>
Cari record berdasarkan kriteria, atau buat baru jika tidak ditemukan.
Sourcefn update_or_create<'life0, 'async_trait, K, V>(
pool: &'life0 DatabasePool,
attributes: impl IntoIterator<Item = (K, V)> + Send + 'async_trait,
values: impl IntoIterator<Item = (K, V)> + Send + 'async_trait,
) -> Pin<Box<dyn Future<Output = Result<Self, Error>> + Send + 'async_trait>>
fn update_or_create<'life0, 'async_trait, K, V>( pool: &'life0 DatabasePool, attributes: impl IntoIterator<Item = (K, V)> + Send + 'async_trait, values: impl IntoIterator<Item = (K, V)> + Send + 'async_trait, ) -> Pin<Box<dyn Future<Output = Result<Self, Error>> + Send + 'async_trait>>
Update record jika ditemukan berdasarkan atribut, atau buat baru jika tidak ada (Laravel: updateOrCreate).
Sourcefn find_many<'life0, 'life1, 'async_trait>(
pool: &'life0 DatabasePool,
ids: &'life1 [i64],
) -> Pin<Box<dyn Future<Output = Result<Vec<Self>, Error>> + Send + 'async_trait>>where
'life0: 'async_trait,
'life1: 'async_trait,
Self: 'async_trait,
fn find_many<'life0, 'life1, 'async_trait>(
pool: &'life0 DatabasePool,
ids: &'life1 [i64],
) -> Pin<Box<dyn Future<Output = Result<Vec<Self>, Error>> + Send + 'async_trait>>where
'life0: 'async_trait,
'life1: 'async_trait,
Self: 'async_trait,
Ambil sekumpulan record berdasarkan array of primary key IDs (Laravel: findMany).
Sourcefn restore<'life0, 'async_trait>(
pool: &'life0 DatabasePool,
id: i64,
) -> Pin<Box<dyn Future<Output = Result<bool, Error>> + Send + 'async_trait>>where
'life0: 'async_trait,
Self: 'async_trait,
fn restore<'life0, 'async_trait>(
pool: &'life0 DatabasePool,
id: i64,
) -> Pin<Box<dyn Future<Output = Result<bool, Error>> + Send + 'async_trait>>where
'life0: 'async_trait,
Self: 'async_trait,
Pulihkan record yang telah di-soft-delete (Laravel: restore)
Sourcefn force_delete<'life0, 'async_trait>(
pool: &'life0 DatabasePool,
id: i64,
) -> Pin<Box<dyn Future<Output = Result<bool, Error>> + Send + 'async_trait>>where
'life0: 'async_trait,
Self: 'async_trait,
fn force_delete<'life0, 'async_trait>(
pool: &'life0 DatabasePool,
id: i64,
) -> Pin<Box<dyn Future<Output = Result<bool, Error>> + Send + 'async_trait>>where
'life0: 'async_trait,
Self: 'async_trait,
Hapus record secara permanen (Hard Delete) dari database (Laravel: forceDelete)
Sourcefn truncate<'life0, 'async_trait>(
pool: &'life0 DatabasePool,
) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send + 'async_trait>>where
'life0: 'async_trait,
Self: 'async_trait,
fn truncate<'life0, 'async_trait>(
pool: &'life0 DatabasePool,
) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send + 'async_trait>>where
'life0: 'async_trait,
Self: 'async_trait,
Kosongkan seluruh data tabel model (Laravel: truncate)
Sourcefn with_trashed<'a>(pool: &'a DatabasePool) -> QueryBuilder<'a, Self>
fn with_trashed<'a>(pool: &'a DatabasePool) -> QueryBuilder<'a, Self>
Shortcut query yang menyertakan data yang sudah di-soft-delete (Laravel: withTrashed)
Sourcefn only_trashed<'a>(pool: &'a DatabasePool) -> QueryBuilder<'a, Self>
fn only_trashed<'a>(pool: &'a DatabasePool) -> QueryBuilder<'a, Self>
Shortcut query yang HANYA mengambil data yang telah di-soft-delete (Laravel: onlyTrashed)
Sourcefn create<'life0, 'async_trait, K, V>(
pool: &'life0 DatabasePool,
data: impl IntoIterator<Item = (K, V)> + Send + 'async_trait,
) -> Pin<Box<dyn Future<Output = Result<Self, Error>> + Send + 'async_trait>>
fn create<'life0, 'async_trait, K, V>( pool: &'life0 DatabasePool, data: impl IntoIterator<Item = (K, V)> + Send + 'async_trait, ) -> Pin<Box<dyn Future<Output = Result<Self, Error>> + Send + 'async_trait>>
Buat record baru dari key-value pairs secara dinamis.
fn has_many<'life0, 'life1, 'async_trait, R>(
pool: &'life0 DatabasePool,
foreign_key: &'life1 str,
local_id: i64,
) -> Pin<Box<dyn Future<Output = Result<Vec<R>, Error>> + Send + 'async_trait>>where
'life0: 'async_trait,
'life1: 'async_trait,
R: Model + 'async_trait,
Sourcefn has_one<'life0, 'life1, 'async_trait, R>(
pool: &'life0 DatabasePool,
foreign_key: &'life1 str,
local_id: i64,
) -> Pin<Box<dyn Future<Output = Result<R, Error>> + Send + 'async_trait>>where
'life0: 'async_trait,
'life1: 'async_trait,
R: Model + 'async_trait,
fn has_one<'life0, 'life1, 'async_trait, R>(
pool: &'life0 DatabasePool,
foreign_key: &'life1 str,
local_id: i64,
) -> Pin<Box<dyn Future<Output = Result<R, Error>> + Send + 'async_trait>>where
'life0: 'async_trait,
'life1: 'async_trait,
R: Model + 'async_trait,
Definisi relasi Has-One.
Contoh: user.has_one::<Profile>(db, "user_id", user.id).await
fn belongs_to<'life0, 'async_trait, R>(
pool: &'life0 DatabasePool,
foreign_key_id: i64,
) -> Pin<Box<dyn Future<Output = Result<R, Error>> + Send + 'async_trait>>where
'life0: 'async_trait,
R: Model + 'async_trait,
Sourcefn belongs_to_many<'life0, 'life1, 'life2, 'life3, 'async_trait, R>(
pool: &'life0 DatabasePool,
pivot_table: &'life1 str,
foreign_key: &'life2 str,
related_key: &'life3 str,
local_id: i64,
) -> Pin<Box<dyn Future<Output = Result<Vec<R>, Error>> + Send + 'async_trait>>where
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
'life3: 'async_trait,
R: Model + 'async_trait,
fn belongs_to_many<'life0, 'life1, 'life2, 'life3, 'async_trait, R>(
pool: &'life0 DatabasePool,
pivot_table: &'life1 str,
foreign_key: &'life2 str,
related_key: &'life3 str,
local_id: i64,
) -> Pin<Box<dyn Future<Output = Result<Vec<R>, Error>> + Send + 'async_trait>>where
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
'life3: 'async_trait,
R: Model + 'async_trait,
Definisi relasi Many-To-Many.
Contoh: post.belongs_to_many::<Tag>(db, "post_tag", "post_id", "tag_id", post.id).await
Sourcefn eager_load<'life0, 'life1, 'life2, 'async_trait>(
_relation: &'life0 str,
_items: &'life1 mut [Self],
_pool: &'life2 DatabasePool,
) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send + 'async_trait>>where
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
Self: 'async_trait,
fn eager_load<'life0, 'life1, 'life2, 'async_trait>(
_relation: &'life0 str,
_items: &'life1 mut [Self],
_pool: &'life2 DatabasePool,
) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send + 'async_trait>>where
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
Self: 'async_trait,
Eager Load relasi untuk sekumpulan model (N+1 Solution). Di-override oleh model untuk mendukung .with(“relation”)
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".