Documentation
¶
Overview ¶
Package collate folds flat SQL rows into nested DTOs. It replaces the hand-written "seen map[ID]int" collapse idiom and the per-parent child-indexing maps used by the gather-and-merge read models in internal/queries.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Collapse ¶
func Collapse[Row any, K comparable, Parent any, Child any]( rows []Row, key func(Row) K, newParent func(Row) Parent, child func(Row) (Child, bool), attach func(*Parent, Child), ) []Parent
Collapse folds parent×child rows (e.g. a LEFT JOIN result) into one parent per key, in first-seen order. newParent builds the parent from the first row seen for a key; child extracts that row's optional child (return ok=false to skip, e.g. a NULL join); attach appends the child to its parent.
func GroupByMap ¶
func GroupByMap[T any, K comparable, V any](items []T, key func(T) K, val func(T) V) map[K][]V
GroupByMap indexes items by key, transforming each into a value — the side-query "xByGroup" pattern. Order within each slice follows input order.
Types ¶
This section is empty.