StaticContext.Type (StaticContext v0.1.0)

Copy Markdown View Source

Parameterized Ecto type for StaticContext lookup modules.

Stores the entry id as a string in the database. Loads the full struct via module.get!/1 on read. Casts from a string id or an already-resolved struct.

Usage in a schema

field :mine_state_id, :string
field :mine_state, StaticContext.Type, module: MineStates, source: :mine_state_id

The _id field holds the raw string (used in changesets, forms, and DB storage). The virtual field holds the resolved struct (read-only, populated on DB load).