View Source Sorcery.Src (Sorcery v0.2.2)

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: "..."}, })

Src.get_in(src, [:user, 1]) => %{id: 1, name: "..."} Src.get_in(src, [:something, 123]) => %{id: 123, foo: 123421} Src.get_in(src, [:something, 123, :foo]) => 123421

Link to this section Summary

Functions

Returns all original and/or changed ids for a table. Note, this will return an id even after applying Src.delete.

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

Returns all original and/or changed ids for a table. Note, this will return an id even after applying Src.delete.

Link to this function

intercept(src, interceptors)

View Source

Process a list of interceptor functions, each taking, and returning a Src.

Link to this function

new(db \\ %{}, args \\ %{})

View Source
Link to this function

time_backward(src, steps)

View Source

Send Src back in time to its state from n interceptors ago.

Link to this function

time_forward(src, steps)

View Source

Send Src past n interceptors without being changed by them.

Link to this function

update_in(src, path, cb)

View Source