Translixir (translixir v0.4.0) View Source

Documentation for Translixir.

Link to this section Summary

Functions

  1. entity({:ok, <PID>}, entity_crux_id)
  2. entity({:ok, <PID>}, entity_crux_id, transaction_time, valid_time) POSTs an ID at CruxDB endpoint [/entity[?[transaction-time=<transaction_time>]&[valid-time=<valid_time>]]}(https://www.opencrux.com/reference/20.09-1.12.1/http.html#entity)
  • transaction_time and valid_time are in DateTime format

Returns

  1. entity!(<PID>, entity_crux_id)
  2. entity!(<PID>, entity_crux_id, transaction_time, valid_time) POSTs an ID at CruxDB endpoint /entity[?[transaction-time=<transaction_time>]&[valid-time=<valid_time>]]
  • transaction_time and valid_time are in DateTime format

Returns

entity_history({:ok, <PID>}, entity_hash, order, with_docs \ false) GETs an CruxdD hash at CruxDB endpoint /entity-history/<hash>?sort-order=<order>&with-docs=<with_docs>

entity_history_timed({:ok, <PID>}, entity_hash, order, with_docs, timed) GETs an CruxdD hash at CruxDB endpoint /entity-history/<hash>?sort-order=<order>&with-docs=<with_docs>

  1. entity_tx({:ok, <PID>}, entity_crux_id)
  2. entity_tx({:ok, <PID>}, entity_crux_id, transaction_time, valid_time) POSTs an ID at CruxDB endpoint /entity-tx
  • transaction_time and valid_time are in DateTime format

Returns

  1. entity_tx!(<PID>, entity_crux_id)
  2. entity_tx!(<PID>, entity_crux_id, transaction_time, valid_time) POSTs an ID at CruxDB endpoint /entity-tx
  • transaction_time and valid_time are in DateTime format

Returns

entity_history!(<PID>, entity_hash, order, with_docs \ false) GETs an CruxdD hash at CruxDB endpoint /entity-history/<hash>?sort-order=<order>&with-docs=<with_docs>

query!(<PID>, query) POSTs a Query at CruxDB endpoint /query

tx_log({:ok, <PID>}, actions) POSTs a collection of Action at CruxDB endpoint /tx-log

tx_log!(<PID>, actions) POSTs a collection of Action at CruxDB endpoint /tx-log

tx_logs({:ok, <PID>}) GETs at CruxDB endpoint /tx-log

tx_logs!(<PID>) GETs at CruxDB endpoint /tx-log

Link to this section Functions

Specs

entity(
  {:ok, atom() | pid() | {atom(), any()} | {:via, atom(), any()}},
  atom() | binary() | integer()
) :: {:error} | {:error, atom()} | {:ok, any()}
  1. entity({:ok, <PID>}, entity_crux_id)
  2. entity({:ok, <PID>}, entity_crux_id, transaction_time, valid_time) POSTs an ID at CruxDB endpoint [/entity[?[transaction-time=<transaction_time>]&[valid-time=<valid_time>]]}(https://www.opencrux.com/reference/20.09-1.12.1/http.html#entity)
  • transaction_time and valid_time are in DateTime format

Returns:

  • status_2XX -> {:ok, body}
  • _ -> {:error}

Example entity_crux_id:

  • ":jorge-3", :jorge_3 or 3
  • ":jorge-3" and :jorge_3 are not equivalent

Example Response:

  • {:ok, { :crux.db/id :jorge-3, :first-name "Michael", :last-name "Jorge", }}
Link to this function

entity(arg, entity_id, tx_time, valid_time)

View Source

Specs

entity(
  {:ok, atom() | pid() | {atom(), any()} | {:via, atom(), any()}},
  atom() | binary() | integer(),
  DateTime.t(),
  DateTime.t()
) :: {:error} | {:error, atom()} | {:ok, any()}
Link to this function

entity!(client, entity_id)

View Source

Specs

entity!(pid(), atom() | binary() | integer()) :: any()
Link to this function

entity!(client, entity_id, tx_time, valid_time)

View Source

Specs

entity!(pid(), atom() | binary() | integer(), DateTime.t(), DateTime.t()) ::
  any()
  1. entity!(<PID>, entity_crux_id)
  2. entity!(<PID>, entity_crux_id, transaction_time, valid_time) POSTs an ID at CruxDB endpoint /entity[?[transaction-time=<transaction_time>]&[valid-time=<valid_time>]]
  • transaction_time and valid_time are in DateTime format

Returns:

  • status_2XX -> body
  • _ -> exception is raised

Example entity_crux_id:

  • ":jorge-3", :jorge_3 or 3
  • ":jorge-3" and :jorge_3 are not equivalent

Example Response:

  • { :crux.db/id :jorge-3, :first-name "Michael", :last-name "Jorge", }
Link to this function

entity_history(arg, entity_hash, order, with_docs \\ false)

View Source

Specs

entity_history({:ok, pid()}, any(), :asc | :desc, boolean()) :: any()

entity_history({:ok, <PID>}, entity_hash, order, with_docs \ false) GETs an CruxdD hash at CruxDB endpoint /entity-history/<hash>?sort-order=<order>&with-docs=<with_docs>

  • order can be :asc or :desc

Returns:

  • status_2XX -> {:ok, body}
  • _ -> {:error}

Example entity_hash:

  • "9d2c7102d6408d465f85b0b35dfb209b34daadd1"

Example Response (with_docs = false):

  {:ok, [
    %{
      "crux.db/content-hash": %Eden.Tag{
        name: "crux/id",
        value: "9d2c7102d6408d465f85b0b35dfb209b34daadd1"
      },
      "crux.db/valid-time": ~U[2020-10-22 18:18:20.524Z],
      "crux.tx/tx-id": 160,
      "crux.tx/tx-time": ~U[2020-10-22 18:18:20.524Z]
    },
    ...]
  }```
Link to this function

entity_history_timed(arg, entity_hash, order, with_docs, timed)

View Source

Specs

entity_history_timed(
  {:ok, pid()},
  any(),
  :asc | :desc,
  boolean(),
  Translixir.Model.HistoryTimeRange.t()
) :: any()

entity_history_timed({:ok, <PID>}, entity_hash, order, with_docs, timed) GETs an CruxdD hash at CruxDB endpoint /entity-history/<hash>?sort-order=<order>&with-docs=<with_docs>

  • order can be :asc or :desc
  • timed is structured as
    %HistoryTimeRange{
    start_valid_time: DateTime.t(),
    end_valid_time: DateTime.t(),
    start_tx_time: DateTime.t(),
    endt_tx_time: DateTime.t(),
    }

Returns:

  • status_2XX -> {:ok, body}
  • _ -> {:error}

Example entity_hash:

  • "9d2c7102d6408d465f85b0b35dfb209b34daadd1"

Example Response (with_docs = false):

  {:ok, [
    %{
      "crux.db/content-hash": %Eden.Tag{
        name: "crux/id",
        value: "9d2c7102d6408d465f85b0b35dfb209b34daadd1"
      },
      "crux.db/valid-time": ~U[2020-10-22 18:18:20.524Z],
      "crux.tx/tx-id": 160,
      "crux.tx/tx-time": ~U[2020-10-22 18:18:20.524Z]
    },
    ...]
  }```
Link to this function

entity_tx(arg, entity_id)

View Source

Specs

entity_tx(
  {:ok, atom() | pid() | {atom(), any()} | {:via, atom(), any()}},
  atom() | binary() | integer()
) :: {:error} | {:error, atom()} | {:ok, any()}
  1. entity_tx({:ok, <PID>}, entity_crux_id)
  2. entity_tx({:ok, <PID>}, entity_crux_id, transaction_time, valid_time) POSTs an ID at CruxDB endpoint /entity-tx
  • transaction_time and valid_time are in DateTime format

Returns:

  • status_2XX -> {:ok, body}
  • _ -> {:error}

Example entity_crux_id:

  • ":jorge-3", :jorge_3 or 3
  • ":jorge-3" and :jorge_3 are not equivalent

Example Response:

  • {:ok, "{:crux.db/id #crux/id "be21bd5ae7f3334b9b8abb185dfbeae1623088b1", :crux.db/content-hash #crux/id "9d2c7102d6408d465f85b0b35dfb209b34daadd1", :crux.db/valid-time #inst "2020-10-16T01:51:50.568-00:00", :crux.tx/tx-time #inst "2020-10-16T01:51:50.568-00:00", :crux.tx/tx-id 4}"}
Link to this function

entity_tx(arg, entity_id, tx_time, valid_time)

View Source

Specs

entity_tx(
  {:ok, atom() | pid() | {atom(), any()} | {:via, atom(), any()}},
  atom() | binary() | integer(),
  DateTime.t(),
  DateTime.t()
) :: {:error} | {:error, atom()} | {:ok, any()}
Link to this function

entity_tx!(client, entity_id)

View Source

Specs

entity_tx!(pid(), atom() | binary() | integer()) :: any()
  1. entity_tx!(<PID>, entity_crux_id)
  2. entity_tx!(<PID>, entity_crux_id, transaction_time, valid_time) POSTs an ID at CruxDB endpoint /entity-tx
  • transaction_time and valid_time are in DateTime format

Returns:

  • status_2XX -> body
  • _ -> exception is raised

Example entity_crux_id:

  • ":jorge-3", :jorge_3 or 3
  • ":jorge-3" and :jorge_3 are not equivalent

Example Response:

  • "{:crux.db/id #crux/id "be21bd5ae7f3334b9b8abb185dfbeae1623088b1", :crux.db/content-hash #crux/id "9d2c7102d6408d465f85b0b35dfb209b34daadd1", :crux.db/valid-time #inst "2020-10-16T01:51:50.568-00:00", :crux.tx/tx-time #inst "2020-10-16T01:51:50.568-00:00", :crux.tx/tx-id 4}"
Link to this function

entity_tx!(client, entity_id, tx_time, valid_time)

View Source

Specs

entity_tx!(pid(), atom() | binary() | integer(), DateTime.t(), DateTime.t()) ::
  any()

Specs

query({:ok, atom() | pid() | {atom(), any()} | {:via, atom(), any()}}, any()) ::
  {:error} | {:error, atom()} | {:ok, any()}

entity_history!(<PID>, entity_hash, order, with_docs \ false) GETs an CruxdD hash at CruxDB endpoint /entity-history/<hash>?sort-order=<order>&with-docs=<with_docs>

  • order can be :asc or :desc

Returns:

  • status_2XX -> {:ok, body}
  • _ -> {:error}

Example entity_hash:

  • "9d2c7102d6408d465f85b0b35dfb209b34daadd1"

Example Response (with_docs = false):

  [
    %{
    "crux.db/content-hash": %Eden.Tag{
  EntityHistory.entity_history(url, headers, entity_hash, with_docs, order)
  query = %{}
    |> Query.find(["?n"])
    |> Query.where([
      "?n :first-name ?p",
    ])
    |> Query.args(["?p "Michael""])
    |> Query.with_full_results
    |> Query.build



  client
  |> query(query)
  |> IO.inspect
  # {:ok,
  #   [
  #     #Array<[
  #       %{"crux.db/id": :"jorge-3", "first-name": "Michael", "last-name": "Jorge"}
  #     ], fixed=false, default=nil>
  #   ]}

Specs

query!(pid(), any()) :: any()

query!(<PID>, query) POSTs a Query at CruxDB endpoint /query

Specs

tx_log({:ok, pid()}, any()) :: {:error} | {:ok, any()}

tx_log({:ok, <PID>}, actions) POSTs a collection of Action at CruxDB endpoint /tx-log

Usage:

  put = action(:put, "{ :crux.db/id :jorge-3, :first-name "Michael", :last-name "Jorge", }")

  Client.new("localhost", "3000")
  |> tx_log(put)
  |> IO.inspect

Returns:

  • status_2XX -> {:ok, body}
  • _ -> {:error}

Example Action:

  • { :crux.db/id :jorge-3, :first-name "Michael", :last-name "Jorge", }

Example Response:

  • {:ok, "{:crux.tx/tx-id 7, :crux.tx/tx-time #inst "2020-07-16T21:50:39.309-00:00"}"}
Link to this function

tx_log!(client, actions)

View Source

Specs

tx_log!(pid(), any()) :: any()

tx_log!(<PID>, actions) POSTs a collection of Action at CruxDB endpoint /tx-log

Returns:

  • status_2XX -> body
  • _ -> exception is raised

Specs

tx_logs({:ok, pid()}) :: {:error} | {:ok, any()}

tx_logs({:ok, <PID>}) GETs at CruxDB endpoint /tx-log

Returns:

  • status_2XX -> {:ok, body}
  • _ -> {:error}

Example Response:

  {:ok,
    ({:crux.tx/tx-id 0, :crux.tx/tx-time #inst "2020-10-14T03:48:43.298-00:00", :crux.tx.event/tx-events
      [[:crux.tx/put #crux/id "be21bd5ae7f3334b9b8abb185dfbeae1623088b1" #crux/id "9d2c7102d6408d465f85b0b35dfb209b34daadd1"]]}
    {:crux.tx/tx-id 1, :crux.tx/tx-time #inst "2020-10-16T01:10:08.451-00:00", :crux.tx.event/tx-events
      [[:crux.tx/put #crux/id "be21bd5ae7f3334b9b8abb185dfbeae1623088b1" #crux/id "9d2c7102d6408d465f85b0b35dfb209b34daadd1"]]})}

Specs

tx_logs!(pid()) :: any()

tx_logs!(<PID>) GETs at CruxDB endpoint /tx-log

Returns:

  • status_2XX -> body
  • _ -> exception is raised