Skip to main content

fetch_with_prefetch_pool

Function fetch_with_prefetch_pool 

Source
pub async fn fetch_with_prefetch_pool<P, C>(
    parent_qs: QuerySet<P>,
    child_fk_column: &'static str,
    pool: &Pool,
) -> Result<Vec<(P, Vec<C>)>, ExecError>
where P: Model + for<'r> FromRow<'r, PgRow> + MaybeMyFromRow + LoadRelated + MaybeMyLoadRelated + HasPkValue + Send + Unpin, C: Model + for<'r> FromRow<'r, PgRow> + MaybeMyFromRow + LoadRelated + MaybeMyLoadRelated + FkPkAccess + Send + Unpin,
Expand description

fetch_with_prefetch against either backend. Bi-dialect counterpart of fetch_with_prefetch — fetches parents + children in two round trips and stitches each child onto its parent via [FkPkAccess]. Bounds add MaybeMyFromRow + MaybeMyLoadRelated over the &PgPool version’s bounds; every #[derive(Model)] type satisfies them automatically.

FkPkAccess doesn’t need a MySQL counterpart — it reads i64 values from struct fields after decoding, with no Row dependency, so the same trait works against either backend.

§Errors

As fetch_with_prefetch.