AggregateProjection

zio.blocks.projection.AggregateProjection

Helpers for global aggregate projections.

Global projections share a single underlying store file (global/.db) and receive events from all sources regardless of entity routing. The entity identifier acts as the grouping key (for example a date string "2025-08-26").

The store layer guarantees that Increment / Decrement / Max / Min FieldUpdates translate to atomic SQL (COALESCE(col,0)+?, MAX(...), MIN(...)) and that a missing aggregate row is materialised on-the-fly via INSERT OR IGNORE before the UPDATE. Upsert uses the SQLite INSERT ... ON CONFLICT DO UPDATE form (falls back to INSERT OR REPLACE when the driver does not advertise conflict support).

Attributes

Source
AggregateProjection.scala
Graph
Supertypes
class Object
trait Matchable
class Any
Self type

Members list

Type members

Classlikes

final case class DailyStats(date: String, userCount: Int, repoCount: Int, peak: Long)

Example model used by the aggregate spec tests: daily statistics bucketed by date (String with @Modifier.id).

Example model used by the aggregate spec tests: daily statistics bucketed by date (String with @Modifier.id).

Attributes

Companion
object
Source
AggregateProjection.scala
Supertypes
trait Serializable
trait Product
trait Equals
class Object
trait Matchable
class Any
Show all
object DailyStats

Attributes

Companion
class
Source
AggregateProjection.scala
Supertypes
trait Product
trait Mirror
class Object
trait Matchable
class Any
Self type
DailyStats.type

Value members

Concrete methods

Build a chunk of atomic counter increments for convenient aggregate use.

Build a chunk of atomic counter increments for convenient aggregate use.

Attributes

Source
AggregateProjection.scala
def dec(field: String, by: Long = ...): Decrement

Attributes

Source
AggregateProjection.scala
def globalWithCounters[A : Schema](name: String, bindings: List[(String, Any => String)] = ...): Projection[A]

Convenience wrapper creating a global spec whose handlers emit atomic counter updates.

Convenience wrapper creating a global spec whose handlers emit atomic counter updates.

Attributes

Source
AggregateProjection.scala
def inc(field: String, by: Long = ...): Increment

Field-level counter helpers re-exported for discoverability.

Field-level counter helpers re-exported for discoverability.

Attributes

Source
AggregateProjection.scala
def max(field: String, value: Long): Max

Attributes

Source
AggregateProjection.scala
def min(field: String, value: Long): Min

Attributes

Source
AggregateProjection.scala
def set(field: String, value: Any): Set

Attributes

Source
AggregateProjection.scala