import type { DerivationStrategyHandle } from './types.js'; /** * `withRollup` — aggregate many child records onto a single field of their * parent. The reverse of a join: instead of reading children * on demand, the parent carries a maintained summary. * * ```ts * withRollup({ * from: 'sales', // child collection (the trigger) * key: 'buyerId', // FK on the child → parent id * into: 'buyers', // parent collection * field: 'revenueByYear', // field on the parent to maintain * compute: (sales) => groupSumByYear(sales, 'total'), * }) * ``` * * On every write OR delete of a `from` record, the parent at id `child[key]` * is recomputed: `compute(allChildren where child[key] === parentId)` is * patched onto `parent[field]`. A parent write also recomputes its own * aggregate (so a parent created after its children still fills in). Only the * `field` is touched — the rest of the parent record is never clobbered — and * a value-equality guard suppresses no-op writes. The aggregate is gap-free * with respect to child inserts, updates, and deletes. * * Desugars to a `withDerivation` strategy carrying a `rollup` marker; dispatch * handles it without invoking the executor. Eager-only in this slice. */ export declare function withRollup = Record, TParent extends Record = Record>(config: { from: string; key: keyof TChild & string; into: string; field: keyof TParent & string; compute: (children: TChild[]) => unknown; }): DerivationStrategyHandle;