Fork me on GitHub

Has anyone worked on a Datomic system that links to something like PostGIS? I’m thinking about keeping all the important info in Datomic and linking to the location data, but I’m wondering if anyone else has given any thought to how to keep that link as immutable as possible or any other real life gotchas that I haven’t considered yet.

Ethan Miller14:01:35

Where above it says taxonomy read “schema"


If I have an attribute :event/order declared as :db.unique/value is there any way of asking datomic for a set of all attribute values?


With good performance. Want to use it for autocompletion


There are magnitudes more events than orders


Not :db.unique/value since that wouldn't work... The question is more if I can get the set of values in a fast way


I could make another entity :order and do references, but it seems kind of wasteful


@alqvist Datalog? [:find ?order :where [_ :event/order ?order]] or transducer + datoms index? (into #{} (comp (map :v) (distinct)) (seq (d/datoms db :avet :event/order)))


doubt you’d find a faster way than one of those two


if you have a LOT of usages, you could maintain a set separately as you discover new ones. so, move the work to transactor functions or the like.


my code assumes you’re :db/index true or :db/unique


@ezmiller77 well what is the transaction?

Ethan Miller17:01:44

@pesterhazy you mean what was the actual transact call? It looked like this:

(def arb-tx (-> (io/resource "schemas/arb.edn")

(pprint (<!! (client/transact conn {:tx-data arb-tx})))
where “schemas/arb.edn” is the schema listed in that stackoverflow question. I guess I should have included that in the Q.


Try calling the transactions manually from the repl


why do you call first there?


tx-data is supposed to be a collection of txs

Ethan Miller17:01:40

just because (read-all) spits out a vector

Ethan Miller17:01:26

so arb-tx looked like: [[ <taxonomy definition maps> ]]

Ethan Miller17:01:40

instead of [ <taxonomy definition maps> ]

Ethan Miller17:01:19

read-all looks like:

Ethan Miller17:01:25

(defn read-all
  "Read all forms in f, where f is any resource that can
   be opened by io/reader"
  (Util/readAll (io/reader f)))

Ethan Miller17:01:32

(copied from day-of-datomic)


do you see the same error when you run the code from the repl?

Ethan Miller18:01:06

although removing first, I get this error, also totally inscrutable to me:

{:datomic.client-spi/request-id "9c59aa1c-6127-45fd-87b2-afce72223ce1",
 :cognitect.anomalies/category :cognitect.anomalies/incorrect,
 ":db.error/not-a-data-function Unable to resolve data function: {:db/id {:idx -1000000, :part :db.part/db}, :db/ident :arb/title, :db/unique :db.unique/identity, :db/valueType :db.type/string, :db/cardinality :db.cardinality/one, :db/fulltext true, :db/index true, :db.install/_attribute :db.part/db}",
 [{:database-id "datomic:",
   :t 1004,
   :next-t 1009,
   :history false}]}

Ethan Miller18:01:38

i haven’t been able to figure out how to run it from the repl yet b/c I haven’t figured out how to do the edn file import from there


why don't you try transacting a simple map first?


then add stuff one by one

Ethan Miller18:01:53

not sure what you mean by a simple map?


@(d/transact (rdc) [{:db/id (d/tempid :db.part/user) :db/doc "hello"}])


I guess from the client api it looks a bit different

Ethan Miller18:01:00

oh well that i’ve done before

Ethan Miller18:01:08

but i can try it again if you think it’s helpful.


well if you start with that and then add things bit by bit, I think you may be able to narrow in on the problem

Ethan Miller18:01:09

the command you have there is using the datomic api right?

Ethan Miller18:01:16

as opposed to the client?

Ethan Miller18:01:05

damn, can’t even manage to enter that edn structure into the repl

Ethan Miller18:01:16

gonna have to pick this up later.

Ethan Miller18:01:27

thanks for trying to help @pesterhazy

Ethan Miller18:01:35

the first line there in the schema defn :db/id #db/id [:db.part/db], is being interpreted as a function, which now that i look at it makes sense, so I get this error:

user=> (def arb-title [{:db/id #db/id [:db/part/db]}])
IllegalStateException Attempting to call unbound fn: #'datomic.db/id-literal  clojure.lang.Var$Unbound.throwArity (
RuntimeException Unmatched delimiter: }  clojure.lang.Util.runtimeException (
RuntimeException Unmatched delimiter: ]  clojure.lang.Util.runtimeException (
RuntimeException Unmatched delimiter: )  clojure.lang.Util.runtimeException (


@robert-stuttaford Datalog. Probably going with maintaining a separate set since there might be millions of events.


thanks for the answer


@ezmiller77 that ain't right: :db/part/db