Fork me on GitHub
#datomic
<
2023-11-30
>
Diego Herrera15:11:30

Hello! how are you? I'm fairly new to datomic, and was wondering if there is a docker image or similar reference for setting up datomic on top of postgresql

Ben Kamphaus16:11:23

w/the caveat that I haven’t used it, this exists: https://github.com/galuque/datomic-compose and looks similar to other datomic + postgres docker compose solutions I’ve seen in private code in various places.

bhurlow22:11:23

this is a lot easier now that the releases can be pulled from a public URL

bhurlow22:11:01

our images currently start from FROM debian:bookworm-slim

bhurlow22:11:32

install whatever java version you’re using, and then pull the dist zip like:

bhurlow22:11:33

RUN curl  -O
RUN unzip datomic-pro-${datomic_version}.zip 
RUN mv datomic-pro-${datomic_version}/* /opt/datomic

Mitchell Harris22:11:49

So, I’ve got a collection of ids, and I need to find which of these ids don’t exist in my datomic database. I could pull back all of the records that do exist, and filter them out, but that seems inefficient if my DB gets big. I’m able to write a simple query to do this if I’m looking at one and only one attribute: (e.g.)

(d/q '[:find ?id
       :in $ [?id ...]
       :where
       (not
        [_ :observed-record/record-id ?id])]
     (d/db conn)
     '("not-in-db" "in-db")) => [["not-in-db"]]
However, I can’t find a way to make it work when I’m looking at two attributes: (e.g.)
(d/q '[:find ?id
       :in $ ?namespace [?id ...]
       :where
       (not-join [?id]
                 (and
                  [?e :observed-record/namespace ?namespace]
                  [?e :observed-record/record-id ?id]))]
     (d/db conn)
     "my-namespace"
     '("not-in-db" "in-db"))
=> ; processing rule: (q__23841 ?id), message: Syntax error compiling at (0:0).
Any ideas how to make the second query work?

cch122:11:45

Probably just an error in creating the example for Slack, but where is the db arg to d/q?

💯 1
Mitchell Harris22:11:58

Fixed. Using some tool that had partially applied the db already.

cch122:11:13

In addition to ?id, you might need to require that ?namespace be bound before the not-join (which it is, but it can’t hurt to signal this to the query parser)

thanks2 1
favila22:11:24

not-join doesn’t use and

1
favila22:11:45

and only groups or alternatives

thanks2 1
Mitchell Harris22:11:15

Ah. That’s it. No ands in not-join . That fixed it.

Mitchell Harris22:11:44

And now I’m wondering why I thought it did need an and :face_with_spiral_eyes:

Mitchell Harris22:11:51

@U0698L2BU Out of curiosity, how would I signal that to the query parser?

favila22:11:06

The same way as in rules, with the extra [] e.g. (not-join [[?id ?namespace]] …)

cch122:11:48

I was thinking (not-join [?id ?namespace] ...).

favila22:11:50

that would work too. not gets moved around to the highest spot that still satisfies its bindings. not can’t work without everything being bound that it unifies with, because it doesn’t produce rows, it removes them

✔️ 1
Mitchell Harris22:11:54

Huh. Given that I didn’t provide ?namespace in the (not-join […]) here, how would that have even worked?

cch122:11:57

(I was actually working on the observation that the namespace is a constant for the query and thus there is no need to bind it in a tuple).

👍 1
cch123:11:14

Well, it is bound. So you are covered. It’s bound as an input (constant).