Sublimate (Sublimate v0.1.5)
Copy MarkdownSublimate is a helper library that builds database trigger logic for incremental updates to a destination table.
The data source can be a single source table or multiple joined tables. Changes to any of the source tables are staged to a deltas table. A merge function can then be applied - on demand or at scheduled intervals - to copy the changes to the destination table.
Sublimate maintains the destination table incrementally as the source changes; the consumer application/library defines what the destination contains and how staged changes merge into it.
One example of a consuming library is Refine ➚, which keeps a facets table up to date with changes in source tables.
Building blocks
Projection
The engine that builds and runs the infrastructure (deltas table, triggers) that keeps the destination table synchronized with its source tables, without knowing anything about the table's contents.
Projection-specific decisions are delegated to the projection's strategy (see below).
See: Sublimate.Projection
Strategy
The implementation of a specific projection. By implementing Sublimate.ProjectionStrategy
callback functions, the consuming application/library instructs the projection how to keep
the destination table synchronized.
See: Sublimate.ProjectionStrategy
Projection data
The attributes the projection operates on: the strategy module, and normalized and validated table and trigger references.
Entry points
For a single projection, the lifecycle is:
install/3sets up a projectionuninstall/3oruninstall_all/3tears down the projectionmerge/3applies staged changes to the destination table
install/3 is composed of two lower-level functions, exposed for advanced use:
create_shared_infrastructure/5creates the deltas table and merge functioninstall_triggers/4installs a projection's source and joined-table triggers
Most consumers only need install/3. The two building blocks let a caller install
several projections against one shared destination table - creating the shared
infrastructure once, then installing each projection's triggers - which install/3,
by recreating the deltas table and merge function on every call, cannot do.
See: Sublimate.Projection