Translixir (translixir v0.4.0) View Source
Documentation for Translixir
.
Link to this section Summary
Functions
entity({:ok, <PID>}, entity_crux_id)
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
andvalid_time
are inDateTime
format
Returns
entity!(<PID>, entity_crux_id)
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
andvalid_time
are inDateTime
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>
entity_tx({:ok, <PID>}, entity_crux_id)
entity_tx({:ok, <PID>}, entity_crux_id, transaction_time, valid_time)
POSTs an ID at CruxDB endpoint/entity-tx
transaction_time
andvalid_time
are inDateTime
format
Returns
entity_tx!(<PID>, entity_crux_id)
entity_tx!(<PID>, entity_crux_id, transaction_time, valid_time)
POSTs an ID at CruxDB endpoint/entity-tx
transaction_time
andvalid_time
are inDateTime
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()}
entity({:ok, <PID>}, entity_crux_id)
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
andvalid_time
are inDateTime
format
Returns:
status_2XX
-> {:ok, body}- _ -> {:error}
Example entity_crux_id
:
":jorge-3"
,:jorge_3
or3
":jorge-3"
and:jorge_3
are not equivalent
Example Response:
{:ok, { :crux.db/id :jorge-3, :first-name "Michael", :last-name "Jorge", }}
Specs
Specs
Specs
entity!(pid(), atom() | binary() | integer(), DateTime.t(), DateTime.t()) :: any()
entity!(<PID>, entity_crux_id)
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
andvalid_time
are inDateTime
format
Returns:
status_2XX
-> body- _ -> exception is raised
Example entity_crux_id
:
":jorge-3"
,:jorge_3
or3
":jorge-3"
and:jorge_3
are not equivalent
Example Response:
{ :crux.db/id :jorge-3, :first-name "Michael", :last-name "Jorge", }
Specs
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]
},
...]
}```
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]
},
...]
}```
Specs
entity_tx( {:ok, atom() | pid() | {atom(), any()} | {:via, atom(), any()}}, atom() | binary() | integer() ) :: {:error} | {:error, atom()} | {:ok, any()}
entity_tx({:ok, <PID>}, entity_crux_id)
entity_tx({:ok, <PID>}, entity_crux_id, transaction_time, valid_time)
POSTs an ID at CruxDB endpoint/entity-tx
transaction_time
andvalid_time
are inDateTime
format
Returns:
status_2XX
-> {:ok, body}- _ -> {:error}
Example entity_crux_id
:
":jorge-3"
,:jorge_3
or3
":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}"}
Specs
Specs
entity_tx!(<PID>, entity_crux_id)
entity_tx!(<PID>, entity_crux_id, transaction_time, valid_time)
POSTs an ID at CruxDB endpoint/entity-tx
transaction_time
andvalid_time
are inDateTime
format
Returns:
status_2XX
-> body- _ -> exception is raised
Example entity_crux_id
:
":jorge-3"
,:jorge_3
or3
":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}"
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>, query)
POSTs a Query
at CruxDB endpoint /query
Specs
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"}"}
Specs
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>})
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>)
GETs at CruxDB endpoint /tx-log
Returns:
status_2XX
-> body- _ -> exception is raised