https://github.com/cldwalker/datomic-client
ruby client for datomic's http api
https://github.com/cldwalker/datomic-client
Last synced: 11 months ago
JSON representation
ruby client for datomic's http api
- Host: GitHub
- URL: https://github.com/cldwalker/datomic-client
- Owner: cldwalker
- License: mit
- Created: 2012-09-07T19:31:41.000Z (over 13 years ago)
- Default Branch: master
- Last Pushed: 2016-03-30T16:09:25.000Z (about 10 years ago)
- Last Synced: 2025-03-11T06:46:48.866Z (about 1 year ago)
- Language: Ruby
- Homepage:
- Size: 215 KB
- Stars: 41
- Watchers: 11
- Forks: 5
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE.txt
Awesome Lists containing this project
README
## Description
This gem provides a simple way to use datomic's [http API](http://docs.datomic.com/rest.html).
## 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
```ruby
# 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)
=> #:put,
:url=>"http://localhost:9000/db/socrates/test-1347638297", :payload=>{}, :headers=>{}},
@net_http=#, @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](http://github.com/cldwalker/datomic-client/issues).
## Contributing
[See here](http://tagaholic.me/contributing.html) 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
* [API documentation](http://docs.datomic.com/rest.html) - Actual documentation now resides on root
url of datomic endpoint
* [Initial announcement](http://blog.datomic.com/2012/09/rest-api.html)
* [Sinatra Example](https://github.com/crnixon/datomic-sinatra-wiki) - Sinatra wiki that uses
datomic-client