0.02
No commit activity in last 3 years
No release in over 3 years
This gem provides a simple way to use datomic's http API - http://docs.datomic.com/rest.html.
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

~> 0.9.2.2
~> 2.11

Runtime

~> 1.0.0
~> 1.6.7
 Project Readme

Description

This gem provides a simple way to use datomic's http API.

Install

Install as a gem:

$ gem install datomic-client

If your application is using a Gemfile, add this to it:

gem 'datomic-client', :require => 'datomic/client'

and then bundle.

Usage

# In another shell in datomic's directory
$ bin/rest 9000 socrates datomic:mem://

# Assuming you have a schema with a :"community/name" attribute
# In project's directory
$ irb -rdatomic/client
>> dbname = 'cosas'
>> datomic = Datomic::Client.new 'http://localhost:9000', 'socrates'
>> resp = datomic.create_database(dbname)
=> #<Datomic::Client::Response:0x0000010157bc58 @body="", @args={:method=>:put,
:url=>"http://localhost:9000/db/socrates/test-1347638297", :payload=>{}, :headers=>{}},
@net_http=#<Net::HTTPCreated 201 Created readbody=true>, @rest_client_response="">
>> resp.code
=> 201
>> resp.body
=> ''

# Most responses are in edn and thus can be accessed natively
>> resp = datomic.query('[:find ?c :where [?c :community/name]]', dbname)
>> resp.data
=> [[1]]

# additional endpoints
>> datomic.database_info(dbname)
>> datomic.transact(dbname, [[:"db/add", 1, :"community/name", "Some Community"]])
>> datomic.datoms(dbname, 'aevt')
>> datomic.range(dbname, :a => "db/ident")
>> datomic.entity(dbname, 1)
>> datomic.events(dbname) {|r| puts "Received: #{r.inspect}" }

Issues

Please report them on github.

Contributing

See here for contribution policies.

Credits

  • @crnixon for adding edn support and improving #query
  • @flyingmachine for starting this with me
  • @timcraft for #db_alias
  • @relevance for fridays to work on this

Links