Fork me on GitHub
#datomic
<
2019-08-29
>
skuttleman00:08:14

Hello. Fairly new to datomic. I'm attempting to write a query that returns entities which have had attributes updated since a point in time. I can't figure out why the first two queries work great, but the third one just hangs for 30 seconds and return Server error.

(d/q '[:find (pull ?e [*])
       :in $all $new
       :where
       [$all ?e :customer/id]
       [$new ?e :customer/first-name]]
     db
     (d/since db t))

(d/q '[:find (pull ?e [*])
       :in $all $new
       :where
       [$all ?e :customer/id]
       [$new ?e :customer/last-name]]
     db
     (d/since db t))

(d/q '[:find (pull ?e [*])
       :in $all $new
       :where
       [$all ?e :customer/id]
       (or [$new ?e :customer/first-name]
           [$new ?e :customer/last-name])]
     db
     (d/since db t))

marshall13:08:50

Check your datomic system logs to see if you had an exception or error in the 3rd one

benoit12:08:50

@skuttleman I wonder if the or clause can only target one src-var. Did you try to put the $new before the or clause? I never encountered this case. Does it mean you cannot write a or clause across src-vars?

benoit12:08:22

For this kind of historical queries I would use the log API and check for the attributes I'm interested in in each transaction since t.

skuttleman13:08:09

@me1740 @marshall Thanks for responding. I ended up getting it to work last night after finding this: https://docs.datomic.com/on-prem/query.html#how-or-clauses-work The or clause can only target one src-var

(d/q '[:find (pull ?e [*])
       :in $all $new
       :where
       [$all ?e :customer/id]
       ($new or
             [?e :customer/first-name]
             [?e :customer/last-name])]
     db
     (d/since db t))

benoit13:08:11

@skuttleman Ok, that's it. Thanks for the relevant link to the docs.

👍 4
dominicm17:08:42

In datomic ions, where would I put something I might normally do in a component/integrant system? e.g. create a postgresql hikari connection pool (yes, yes I know, but this is a clear example).

Mark Addleman17:08:04

I'm using Mount in ions. The only thing that is mildly special is that I have some code in the root of a namespace which checks the environment. If the environment is not the desktop (ie, either :dev or :prod), it mounts the system

dominicm17:08:33

How does code check the environment?

dominicm19:08:42

How do parameters work in development?

marshall19:08:01

Parameters will still use the AWS parameter store in dev get-env will use local environment variable when running locally

dominicm19:08:33

Developers need to set that environment then? (Or I guess the application could default to dev, but that seems potentially dangerous depending on what you do in dev)

marshall19:08:48

either way, yes

m0smith19:08:52

Does datomic support a sort aggregate?

timgilbert20:08:35

Generally no, if you mean something similar to SQL's ORDER BY. In the peer model you'll typically do the sorting in your application code.

m0smith21:08:05

I am running an Ion using the client model