Read Error Error Using Datomic in Light Table

When I evaluate this code in a lighttable:

(ns app.core (:require [datomic.api :refer [q] :as d] :reload-all)) (defn add-person [conn id] (d/transact conn [{:db/id #db/id[:db.part/user -1000001] :person/id id}])) 

I get:

 clojure.lang.ExceptionInfo: No reader function for tag id core.clj:4327 clojure.core/ex-info 

Does anyone know what is going on?

+8
clojure datomic lighttable
source share
3 answers

This tutorial is attributed to stuart halloway and Bobby Calderwood :

 (use :reload 'datomic.samples.repl) (easy!) (def conn (scratch-conn)) ;; in data, use data literals for tempids (def tx-data [{:db/id #db/id[:db.part/user] :db/doc "Example 1"}]) (transact conn tx-data) ;; in code, call tempid to create tempids (let [id (tempid :db.part/user) doc "Example 2"] (transact conn [{:db/id id :db/doc doc}])) ;; same argument applies to functions: ;; use #db/fn literals in data ;; use Peer.function or d/function in code ;; broken, uses db/fn literal in code (transact conn [{:db/id #db/id [:db.part/user] :db/ident :hello :db/fn #db/fn {:lang "clojure" :params [] :code '(println :hello)}}]) ;; corrected: used d/function to construct function (transact conn [{:db/id (d/tempid :db.part/user) :db/ident :hello :db/fn (d/function {:lang "clojure" :params [] :code '(println :hello)})}]) (d/invoke (db conn) :hello) 

Source : https://github.com/Datomic/day-of-datomic/blob/master/samples/literals_vs_code.clj

+2
source share

There seems to be a problem trying to install :person/id . After the #db/id[:db.part/user -1000001] , you have a temporary identifier for adding data.

You can start setting attributes for an object using things like :person/name name .

If you are trying to create a type of "public identifier", this blog post may be helpful.

0
source share

This is a problem in nREPL. The way I solved this is to run REPL on the command line with:

 lein repl 

This will start a process with which you can connect from LightTable or Emacs. It will print information, for example:

 nREPL server started on port 51395 on host 127.0.0.1 ^^^^^ 

Now in LightTable add a connection -> Clojure Remote -> 127.0.0.1:XXXXX

XXXXX should equal the port printed with lein repl.

If you are in Emacs, cider has the same problem. Follow the same steps as for running lein repl, then use Mx cider-connect (the default keyword is Cc Mc).

0
source share

All Articles