Fork me on GitHub
#datomic
<
2018-04-30
>
greywolve09:04:37

How do you construct a Datom?

val_waeselynck12:04:51

You could maybe use defrecord and implement the interface

greywolve12:04:32

Ta, I'll try that 🙂

val_waeselynck12:04:43

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

👌 4
greywolve09:04:58

(for mocking purposes, or datom transformation)

robert-stuttaford11:04:38

@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?

greywolve12:04:22

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

Nikso17:04:46

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?

Nikso17:04:49

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

adammiller19:04:48

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).

kirill.salykin17:04:12

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

/usr/local/Cellar/datomic/0.9.5656
  % 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 https://github.com/Homebrew/homebrew-core/blob/master/Formula/datomic.rb Console install with
bin/install-console /usr/local/Cellar/datomic/0.9.5656
Please advice what can be wrong thanks

kirill.salykin17:04:06

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

kirill.salykin17:04:45

sorry for disturbing

bj19:04:39

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 (https://docs.datomic.com/cloud/tutorial/retract.html); however, the datomic.api package accepts only a list of lists as the second argument (https://docs.datomic.com/on-prem/clojure/index.html#datomic.api/transact).

marshall19:04:57

@bj the tutorial you mentioned uses the client API (https://docs.datomic.com/client-api/datomic.client.api.html#var-transact), while the api link you provided is the peer API

bj19:04:00

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

adammiller19:04:03

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 type....it 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)?

adammiller19:04:20

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.

rnagpal19:04:37

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
                :where
                [(user/event-matches-1 ?e ?start ?end ?categories ?levels)]]

rnagpal19:04:24

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

adammiller20:04:10

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

rnagpal20:04:21

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

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

adammiller20:04:58

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:

adammiller20:04:10

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