with

suspend fun <SRCID : Any, SRC : Entity<SRCID>, REF : Entity<*>, L : SizedIterable<SRC>> L.with(vararg relations: KProperty1<out REF, Any?>): L

Loads the given relations for every entity of this SizedIterable up front, one query per relation, instead of one query per entity as it is traversed:

val films = Film.all().with(Film::director).toList()

films.forEach { println(it.director().name) } // no further queries

Returns the same SizedIterable, so it can be used inline in a chain; the entities it loaded are pinned onto it, so collecting it again does not re-query the database.

Use the Iterable overload for entities that are already in memory as a List.


suspend fun <SRCID : Any, SRC : Entity<SRCID>, REF : Entity<*>, L : Iterable<SRC>> L.with(vararg relations: KProperty1<out REF, Any?>): L

Loads the given relations for entities that are already in memory, one query per relation:

val films = Film.all().toList()

films.with(Film::director)

A separate overload from the SizedIterable one because R2DBC's SizedIterable is a Flow, not an Iterable, so a single receiver cannot cover both.