sql_support

Function each_sized_chunk_mapped

source
pub fn each_sized_chunk_mapped<'a, T, U, E, Mapper, DoChunk>(
    items: &'a [T],
    chunk_size: usize,
    to_sql: Mapper,
    do_chunk: DoChunk,
) -> Result<(), E>
where T: 'a, U: ToSql + 'a, Mapper: Fn(&'a T) -> U, DoChunk: FnMut(Map<Iter<'a, T>, &Mapper>, usize) -> Result<(), E>,
Expand description

Utility to help perform batched updates, inserts, queries, etc. This is the low-level version of this utility which is wrapped by each_chunk and each_chunk_mapped, and it allows you to provide both the mapping function, and the chunk size.

Note: mapped basically just refers to the translating of T to some U where U: ToSql using the to_sql function. This is useful for e.g. inserting the IDs of a large list of records.