View Source Sorcery.Src (Sorcery v0.1.0)
This is the quintessential single source of truth in the app.
The db format
The first thing to understand is the concept of a 'db'. Every DB is in the following format: db = %{ :user => %{
1 => %{id: 1, name: "Aaron"},
3 => %{id: 3, name: "Not Aaron"},
}, :comment => %{
78 => %{id: 78, user_id: 1, body: "Hello"}
} }
Note the the top level keys are atom names related to an ecto schema.
For example
src = Src.new(%{ :user => %{id: 1, name: "..."}, :user => %{id: 2, name: "..."}, })
get_in(src, [:user, 1]) => %{id: 1, name: "..."} get_in(src, [:something, 123]) => %{id: 123, foo: 123421} get_in(src, [:something, 123, :foo]) => 123421
Link to this section Summary
Functions
Get all ids for a given table @TODO This might need more work if you delete an entity and the id is still in original_db.
Process a list of interceptor functions, each taking, and returning a Src.
Send Src back in time to its state from n interceptors ago.
Send Src past n interceptors without being changed by them.
Link to this section Functions
Get all ids for a given table @TODO This might need more work if you delete an entity and the id is still in original_db.
Process a list of interceptor functions, each taking, and returning a Src.
Send Src back in time to its state from n interceptors ago.
Send Src past n interceptors without being changed by them.