ProductPromotion
Logo

Elixir

made by https://0x3d.site

GitHub - edubkendo/datomex: Elixir driver for the Datomic REST API
Elixir driver for the Datomic REST API. Contribute to edubkendo/datomex development by creating an account on GitHub.
Visit Site

GitHub - edubkendo/datomex: Elixir driver for the Datomic REST API

GitHub - edubkendo/datomex: Elixir driver for the Datomic REST API

Datomex

Low level Elixir drivers for the Datomic database.

API Docs at: http://hexdocs.pm/datomex

Install

Add Datomex and HTTPoison to your mix.exs dependencies:

def deps do
[ {:datomex, "~> 0.0.1"},
  {:httpoison, "~> 0.8.0" } ]
end

Usage

Datomex.start_link "localhost", 8888, "db", "test"

Datomex.databases
# {:ok,
#   %HTTPoison.Response{body: "[\"test\"]",
#   headers: %{"Content-Length" => "8",
#   "Content-Type" => "application/edn;charset=UTF-8",
#   "Date" => "Sun, 23 Nov 2014 08:44:59 GMT",
#   "Server" => "Jetty(8.1.11.v20130520)", "Vary" => "Accept"},
#   status_code: 200}}

Datomex.create_database("test_02")
# {:ok,
#   %HTTPoison.Response{body: "[\"test\" \"test_02\"]",
#   headers: %{"Content-Length" => "18",
#     "Content-Type" => "application/edn;charset=UTF-8",
#     "Date" => "Sun, 23 Nov 2014 08:46:22 GMT",
#     "Server" => "Jetty(8.1.11.v20130520)", "Vary" => "Accept"},
#   status_code: 201}}

movies = """
[
  {:db/id #db/id[:db.part/db]
  :db/ident :movie/title
  :db/valueType :db.type/string
  :db/cardinality :db.cardinality/one
  :db/doc "movie's title"
  :db.install/_attribute :db.part/db}
  {:db/id #db/id[:db.part/db]
  :db/ident :movie/rating
  :db/valueType :db.type/double
  :db/cardinality :db.cardinality/one
  :db/doc "movie's rating"
  :db.install/_attribute :db.part/db}
]
"""
Datomex.transact movies
# {:ok,
#   %HTTPoison.Response{body: "{:db-before {:basis-t 1119, :db/alias \"db/test\"}, :db-after {:basis-t 1120, :db/alias \"db/test\"}, :tx-data [{:e 13194139534432, :a 50, :v #inst \"2014-11-23T08:48:27.678-00:00\", :tx 13194139534432, :added true}], :tempids {-9223367638809264861 64, -9223367638809264860 63}}",
#   headers: %{"Content-Length" => "272",
#     "Content-Type" => "application/edn;charset=UTF-8",
#     "Date" => "Sun, 23 Nov 2014 08:48:27 GMT",
#     "Server" => "Jetty(8.1.11.v20130520)", "Vary" => "Accept"},
#   status_code: 201}}

Datomex.datoms "eavt"
# {:ok,
# %HTTPoison.Response{body: "[{:e 0, :a 10, :v :db.part/db, :tx 13194139533312, :added true}...

Datomex.entity 1
# {:ok,
#   %HTTPoison.Response{body: "{:db/ident :db/add, :db/doc \"Primitive assertion. All transactions eventually reduce to a collection of primitive assertions and retractions of facts, e.g. [:db/add fred :age 42].\", :db/id 1}",
#   headers: %{"Content-Length" => "191",
#     "Content-Type" => "application/edn;charset=UTF-8",
#     "Date" => "Sun, 23 Nov 2014 08:51:32 GMT",
#     "Server" => "Jetty(8.1.11.v20130520)", "Vary" => "Accept"},
#   status_code: 200}}

Datomex.transact(~s([[:db/add #db/id [:db.part/user] :movie/title "trainspotting"]]))
{:ok, %HTTPoison.Response{ body: body }} = Datomex.q(~s([:find ?m :where [?m :movie/title "trainspotting"]]))
movies = Exdn.to_elixir!(body)
# [vector: [17592186045486], vector: [17592186045538], vector: [17592186045481],
# vector: [17592186045483], vector: [17592186045478], vector: [17592186045509],
# vector: [17592186045474], vector: [17592186045468], vector: [17592186045503],
# vector: [17592186045466], vector: [17592186045472], vector: [17592186045499],
# vector: [17592186045530], vector: [17592186045493], vector: [17592186045490],
# vector: [17592186045524], vector: [17592186045521]]

Related Projects

The Exdn edn parser library (API docs) may be used with Datomex, both to parse incoming edn and to generate edn strings from Elixir data structures. Some examples of how this can be done may be found in the tests.

TODO

  • Add docs
  • Tighter integration with exdn.

Articles
to learn more about the elixir concepts.

Resources
which are currently available to browse on.

mail [email protected] to add your project or resources here 🔥.

FAQ's
to know more about the topic.

mail [email protected] to add your project or resources here 🔥.

Queries
or most google FAQ's about Elixir.

mail [email protected] to add more queries here 🔍.

More Sites
to check out once you're finished browsing here.

0x3d
https://www.0x3d.site/
0x3d is designed for aggregating information.
NodeJS
https://nodejs.0x3d.site/
NodeJS Online Directory
Cross Platform
https://cross-platform.0x3d.site/
Cross Platform Online Directory
Open Source
https://open-source.0x3d.site/
Open Source Online Directory
Analytics
https://analytics.0x3d.site/
Analytics Online Directory
JavaScript
https://javascript.0x3d.site/
JavaScript Online Directory
GoLang
https://golang.0x3d.site/
GoLang Online Directory
Python
https://python.0x3d.site/
Python Online Directory
Swift
https://swift.0x3d.site/
Swift Online Directory
Rust
https://rust.0x3d.site/
Rust Online Directory
Scala
https://scala.0x3d.site/
Scala Online Directory
Ruby
https://ruby.0x3d.site/
Ruby Online Directory
Clojure
https://clojure.0x3d.site/
Clojure Online Directory
Elixir
https://elixir.0x3d.site/
Elixir Online Directory
Elm
https://elm.0x3d.site/
Elm Online Directory
Lua
https://lua.0x3d.site/
Lua Online Directory
C Programming
https://c-programming.0x3d.site/
C Programming Online Directory
C++ Programming
https://cpp-programming.0x3d.site/
C++ Programming Online Directory
R Programming
https://r-programming.0x3d.site/
R Programming Online Directory
Perl
https://perl.0x3d.site/
Perl Online Directory
Java
https://java.0x3d.site/
Java Online Directory
Kotlin
https://kotlin.0x3d.site/
Kotlin Online Directory
PHP
https://php.0x3d.site/
PHP Online Directory
React JS
https://react.0x3d.site/
React JS Online Directory
Angular
https://angular.0x3d.site/
Angular JS Online Directory