Permalink
Find file
Fetching contributors…
Cannot retrieve contributors at this time
26 lines (18 sloc) 668 Bytes
#!/usr/bin/env ruby
require 'datomic/client'
require 'edn'
require 'pry'
require './common'
datomic = Datomic::Client.new 'http://localhost:9000', 'example'
dbname = 'customers'
Q_WILLEM = '[:find ?c :in $data :where [$data ?c :customer/name "Willem van Bergen"]]'
query_response = datomic.query(Q_WILLEM, 'customers')
entities = query_response.data.flatten.map {|id| datomic.entity(dbname, id).data}
willem_id = entities.first[:"db/id"]
puts "Willem's id: #{willem_id}"
puts
update = [{:"db/id" => willem_id, :"customer/email" => "willem@shopify.com"}]
t3 = datomic.transact(dbname, update)
puts "Updated Willem with transaction:"
puts
print_entities(t3.data)