 request = require 'request'
+qs = require 'querystring'
 
 class exports.Datomic
 
   constructor: (server, port, alias, name) ->
-    root = "http://#{server}:#{port}/"
-    @db_uri = "#{root}db/#{alias}/#{name}"
+    @root = "http://#{server}:#{port}/"
+    @db_uri = "#{@root}db/#{alias}/#{name}"
 
   createDatabase: (done) ->
     request.put @db_uri, (err, res, body) ->


  parse_opt = (opt) -> if opt.length is 1 then opt[0] else {}

  query_string = (opt) ->
    result = '?' + (field + '=' + value for field, value of opt).join '&'
    return '' if result is '?'
    result

  is_object = (obj) -> obj is Object obj

      opt = parse_opt opt
      eid = '/' + eid

    get "#{@db_uri}/entity#{eid}?#{qs.stringify opt}", done

  q: (query, done) -> done null, 'choose life'
    
