Welcome! Please see the About page for a little more info on how this works.

0 votes
in dev-tools by

Copied over conversation from slack to capture an anomaly with dev-local clients:

I am trying to get started with datomic in a dev-local setup. Any idea why my dev-local db is not found? I can see can see db.log and log.idx files were created.
(ns flow.db
  (:require [datomic.client.api :as d]))
(let [dir     (str (System/getProperty "user.dir") "/var/datomic")
      db-name "flow"
      client  (d/client {:server-type :dev-local
                         :storage-dir dir
                         :system      "dev"})
      _       (d/create-database client db-name)
      conn    (d/connect client {:db-name db-name})]
  conn)
;; Unhandled clojure.lang.ExceptionInfo
;; Db not found: flow
;; #:cognitect.anomalies{:category :cognitect.anomalies/not-found,
;;                       :message "Db not found: flow"}

1 Answer

0 votes
by
edited by
 
Best answer

The issue here is that the d/create-database requires a map of arguments.

https://docs.datomic.com/client-api/datomic.client.api.html#var-create-database

To correctly create a database the the line should have:

(d/create-database client {:db-name db-name})

However this represents an issue with dev-local clients that we should address, in that your create-database call returned true without actually creating a DB. We are investigating further but when create-database is supplied incorrect arguments it should throw an exception instead of returning true:

;Cloud client
(d/create-database client "testing")
Execution error (ExceptionInfo) at datomic.client.impl.shared/api->client-req (shared.clj:258).
Expected a map
;Dev local client
(d/create-database client "testing")
=> true
...