Skip to main content

batch_load_has_many

Function batch_load_has_many 

Source
pub async fn batch_load_has_many<E, K, C, F>(
    fk_values: impl IntoIterator<Item = K> + Send,
    fk_column: C,
    fk_extractor: F,
) -> Result<HashMap<K, Vec<E::Model>>, FrameworkError>
where E: EntityTrait, E::Model: Send + Sync + Clone, K: Clone + Eq + Hash + Send + Sync + 'static, C: ColumnTrait + Send + Sync, F: Fn(&E::Model) -> K + Send + Sync, Value: From<K>,
Expand description

Helper function to batch load has_many relations

§Example

let photos = batch_load_has_many::<animal_photos::Entity, _, _>(
    animal_ids,
    animal_photos::Column::AnimalId,
    |photo| photo.animal_id,
).await?;