Translixir.Model.Action (translixir v0.4.0) View Source

For tx_log functions it is necessary to create Actions. This module is to assist on the creation of this Actions.

Link to this section Summary

Functions

Generates the proper encoding for Actions present in Action Agent

Adds a new Action (put, delete, match, evict) into the Action Agent

Creates a tx_log::delete with argument id, valid_time. Deletes a Document by id at a specific valid_time

Creates a tx_log::evict with argument id

Creates a tx_log::match with argument id, match, valid_time

Creates a new Action list

Creates a tx_log::put with argument id, value, valid_time. It inserts value in CruxDb

Link to this section Functions

Specs

actions(pid()) :: <<_::16, _::_*8>>

Generates the proper encoding for Actions present in Action Agent

actions =
    Action.new()
    |> Action.add_action(Action.evict(:hello))
    |> Action.add_action(
      Action.delete(:my_id, DateTime.from_naive!(~N[2020-10-10 13:26:08.003], "Etc/UTC"))
    )
    |> Action.add_action(
      Action.put(:hello, %{name: "hello", age: 4300000000})
    )
    |> Action.actions()

actions == "[[:crux.tx/evict :hello] [:crux.tx/delete :my_id #inst "2020-10-10T13:26:08.003%2B00:00"]]"

Specs

add_action(pid(), any()) :: pid()

Adds a new Action (put, delete, match, evict) into the Action Agent

Action.add_action(Action.new(), Action.evict(:hello))
Action.add_action(Action.new(), Action.delete(:hello))
Action.add_action(Action.new(), Action.put(:hello, %{name: "hello", age: 4300000000}))

Specs

delete(atom() | integer()) :: <<_::64, _::_*8>>

Creates a tx_log::delete with argument id, valid_time. Deletes a Document by id at a specific valid_time

  • id can be atom or int
  • valid_time is DateTime and optional

delete_date = Action.delete(:my_id, DateTime.from_naive!(~N[2020-10-10 13:26:08.003], "Etc/UTC"))

delete_date == "[:crux.tx/delete :my_id #inst "2020-10-10T13:26:08.003%2B00:00"]"

delete_no_date = Action.delete(:my_id)

delete_no_date == == "[:crux.tx/delete :my_id]"

Specs

delete(atom() | integer(), any()) :: binary()

Specs

evict(atom() | integer()) :: <<_::64, _::_*8>>

Creates a tx_log::evict with argument id

  • id can be atom or int
evict = Action.evict(:hello)

evict ==  "[:crux.tx/evict :hello]"

Specs

match(atom() | integer(), any()) :: <<_::64, _::_*8>>

Creates a tx_log::match with argument id, match, valid_time

  • id can be atom or int
  • match matching edn
  • valid_time is DateTime and optional
Link to this function

match(id, match, valid_time)

View Source

Specs

match(atom() | integer(), any(), any()) :: binary()

Specs

new() :: pid()

Creates a new Action list

Specs

put(atom() | integer(), map()) :: <<_::64, _::_*8>>

Creates a tx_log::put with argument id, value, valid_time. It inserts value in CruxDb

  • id can be atom or int
  • value can be struct or map
  • valid_time is DateTime and optional
put = Actions.put(3, %{first_name: "hello", last_name: "world"})

put == "[:crux.tx/put {:crux.db/id 3 :first_name "hello" :last_name "world"}]"

put_date = Actions.put(3, %User{first_name: "hello", last_name: "world"}, DateTime.from_naive!(~N[2020-10-10 13:26:08.003], "Etc/UTC"))

put_date == "[:crux.tx/put {:crux.db/id 3 :first_name "hello" :last_name "world"} #inst "2020-10-10T13:26:08.003%2B00:00"]"
Link to this function

put(id, value, valid_time)

View Source

Specs

put(atom() | integer(), map(), any()) :: binary()