• Stars
    star
    47
  • Rank 604,146 (Top 12 %)
  • Language
    Elixir
  • License
    MIT License
  • Created almost 10 years ago
  • Updated over 8 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

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.

More Repositories

1

atom-racer

Intelligent code completion for Rust in the Atom Editor. Requires Racer.
CoffeeScript
115
star
2

atom-elm

An atom package providing syntax highlighting and snippets for the Elm language.
CoffeeScript
65
star
3

supermemo

An Elixir implementation of the Supermemo 2 algorithm
Elixir
18
star
4

kitsune

An Elixir library for transforming the representation of data
CSS
11
star
5

OpalConsole

A Chrome extension to compile and run Opal in the browser. Inspired by CoffeeConsole.
JavaScript
10
star
6

smart_diff

A port to Ruby of the htmlizing portion of @yinwang0's psydiff to showcase jruby-parser's semantic diffing
CSS
8
star
7

demoApp

Working through Michael Hartl's Rail's Tutorial, but using Tower.js instead of Ruby on Rails
CoffeeScript
8
star
8

sublime-coffeescript-function-finder

A Sublime Text plug-in for finding function definitions in coffeescript. Adapted from @timdouglas 's sublime-find-function .
Python
5
star
9

towerBot

an irc bot built with Tower.js
CoffeeScript
5
star
10

arango

ArangoDB driver for Elixir.
Elixir
4
star
11

firstApp

Working through Michael Hartl's Rail's Tutorial, but using Tower.js instead of Ruby on Rails โ€”
JavaScript
4
star
12

.dotfiles

Help yourself if you see anything of interest. You might take a peek at my Sublime Text 2 setup.md. Everything as-is, no guarantees, etc.
Shell
4
star
13

spellbook

A code completion tool for Elixir
Elixir
3
star
14

blog

The repo for http://ericwest.io
Elixir
3
star
15

tower-docs

Tower.js Documentation
CoffeeScript
2
star
16

FileTree

A simple ruby library for manipulating filepaths as tree structures
Ruby
2
star
17

Coffee-Ember-Brunch

A fork of @icholy 's Ember-Brunch skeleton converted to coffee-script
CoffeeScript
2
star
18

sampleApp

Working through Michael Hartl's Rail's Tutorial, but using Tower.js instead of Ruby on Rails โ€”
CoffeeScript
2
star
19

first_app

My first app for Ruby on Rails tutorial
Ruby
1
star
20

link_extractor

From ElixirSips, episode 092 http://elixirsips.com/episodes/092_link_extractor.html
Elixir
1
star
21

demo_app

Ruby on Rails Tutorial demo application
Ruby
1
star
22

zappaEmberApp

zappajs, emberjs, brunch, websockets... not working yet!
CoffeeScript
1
star
23

sample_app

Ruby on Rails Tutorial Sample Application
Ruby
1
star
24

microKanren

An implementation of microKanren in Elixir
Elixir
1
star
25

SampleDrools

Attempts at using Drools from JRuby
Java
1
star
26

quote_bot

A simple quote bot for Slack
Ruby
1
star
27

flashMessages

Rails-like flash messages for Towerjs
1
star
28

PDFConverter

A JRubyFX project
Ruby
1
star
29

docker-phoenix

Dockerfile for phoenix
Shell
1
star
30

funfunankideck

grab tweets from https://twitter.com/funfunconv and build anki deck
Elixir
1
star
31

SublimeJRubyFXML

Basic syntax highlighting for FXML and tools for working with JRubyFX
Python
1
star