First Transaction

In this section you will connect to a database and transact data. The instructions that you have created a the database described in First Database. If you used different parameters, you will need to adjust the connect API arguments below to match.



You can run a Clojure REPL using:


Import the Datomic Client library and Clojure core.async:

(require '[clojure.core.async :refer (<!!)]
         '[datomic.client :as client])

Now, connect to the database by calling connect, the access-key/secret pair must match with one used to launch peer-server:

(def conn
  (<!! (client/connect
        {:db-name "firstdb"
         :account-id client/PRO_ACCOUNT
         :secret "mysecret"
         :region "none"
         :endpoint "localhost:8998"
         :service "peer-server"
         :access-key "myaccesskey"})))


Next, add a fact to the system. The following transaction will create a new entity with the doc string "hello world":

(<!! (client/transact conn {:tx-data [{:db/doc "hello world"}]}))

You can close the Clojure REPL with Ctrl+D.

Next: First Query