Fork me on GitHub

How do you construct a Datom?


You could maybe use defrecord and implement the interface


Ta, I'll try that 🙂


Be careful that Datoms are also treated as lists sometimes - as @U0509NKGK said, the most foolproof way is probably to transact

👌 4

(for mocking purposes, or datom transformation)


@greywolve how would this Datom be used? afaik, the only way Datomic’s APIs encounter Datoms is by reading them from storage under the hood. therefore, the simplest way to mock them is to transact. can you explain why making your own would be useful to you?


I guess that's probably the simplest approach, maybe constructing is the wrong approach, even for mocking purposes.


hello here! How do you do your test with the client library? starting an in memory peer-server is a must right? how do you go about cleaning the db?


I tried to use the peer library for testing but ofc the connection doesn't like datomic.client.api functions


I'm not sure there is a great way. What I've done is wrapped the datomic api fns I use and call the client or peer as appropriate for the type of connection I have. Not ideal, but easy enough to do to allow me to use the peer for testing (or perhaps even switch between peer and client later on as needed).


Hi all I am trying to start datomic console but got this:

  % bin/console -p 8080 alias transactor-uri-no-db
bin/console: line 3: bin/classpath: No such file or directory
Error: Could not find or load main class clojure.main
Datomic installed via homebrew formula Console install with
bin/install-console /usr/local/Cellar/datomic/0.9.5656
Please advice what can be wrong thanks


ok, seems I should have used /usr/local/Cellar/datomic/0.9.5656/libexec as path-to-datomic Now everything works


sorry for disturbing


Noting a small documentation inconsistency I hit when trying the tuorial... The datomic retract tutorial documents d/transact as accepting a hash-map with a :tx-data key as its second argument (; however, the datomic.api package accepts only a list of lists as the second argument (


@bj the tutorial you mentioned uses the client API (, while the api link you provided is the peer API


:thumbsup: Thanks. And of course after I sent this I noticed the on-prem versus cloud url paths 😅


Curious @marshall is there a need to make these API's differentiate? As per the question above regarding testing and my own use where I've internally wrapped these calls and dispatched to the correct api based on my connection seems the differences in the api are minor so why not provide consistency so they are interchangeable (at least some core set of api usage)?


Suppose it's not hard to do on our own but I can imagine that many apps are going to end up with very similar layer of wrapping at least the transact and query calls for testing purposes.


Just getting started with datomic queries. I see that we can use predicates. predicates can compare a property with the provided value But I have a predicate, which takes an entity. How can I pass entity to the predicate? I have

(defn event-matches-1 [event start-time end-time categories levels] 
... )

[:find ?e
                :in $ ?start ?end ?categories ?levels
                [(user/event-matches-1 ?e ?start ?end ?categories ?levels)]]


in the function/predicate event-matches-1 I get event as nil


based on what you have there I'd guess that ?e needs to be bound to something before calling the predicate


@adammiller I did try binding ?e also, but that doesn’t work too

[:find ?e
                :in $ ?start ?end ?categories ?levels
                [?e ?entity]
                [(user/event-matches-1 ?entity ?start ?end ?categories ?levels)]]


well, it would have to be bound to some attribute specifically. Not sure what your model looks like but if you have an attribute of say :event/title or something it would be like:


[:find ?e
                :in $ ?start ?end ?categories ?levels
                [?e :event/title]
                [(user/event-matches-1 ?entity ?start ?end ?categories ?levels)]]