Fork me on GitHub
#datomic
<
2022-05-13
>
Ivar Refsdal08:05:51

How do people write database functions (on prem)? Using quote (`'`) as per the https://docs.datomic.com/on-prem/reference/database-functions.html#cancel doesn't feel very ergonomic.

Ivar Refsdal08:05:23

I remember seeing some gist macro-thing for that a long time ago, but I can't find it anymore

enn12:05:07

If you use Conformity to apply your schema it’s just EDN so you don’t have to quote the function definitions. That said, life got a lot easier when we switched to using classpath functions rather than defining them inline in the tx data.

👍 1
Ivar Refsdal14:05:03

Right. I've used conformity. I don't it/EDN makes for more ergonomic function definitions. Classpath functions: Aha. I didn't try that. Only problem I see is a slow/somewhat cumbersome development/deploy cycle... I wrote a small rewrite-clj-thing that extracts a single namespace into a transactor function, maybe I should make that a public library. It has worked well for - well - single namespace functions so far.

enn15:05:24

yeah, the deploy cycle is more cumbersome, but the development cycle is IME much better. You can develop them as normal Clojure functions, test them with or without a database, etc.

enn15:05:29

(with classpath fns)

Ivar Refsdal16:05:08

Right. Thanks :-)

Ivar Refsdal17:05:46

> You can develop them as normal Clojure functions, test them with or without a database, etc. This is also what is possible with the rewrite-clj-"strategy", limited as of now to a single namespace.

Ivar Refsdal08:05:22

Thanks @U3ZUC5M0R, I hadn't heard about datofu. However I don't think/see that it offers better ergonomics for writing database functions though.

dazld08:05:16

@UGJE0MM0W you saw the db-fn helper?

(def foo (db-fn :some/fn 
                '{:lang "clojure"
                  :requires ([datomic.api :as d] [clojure.string :as str])
                  :params [db args]
                  :code (let [{:keys [foo]} args]
                          (prn ::hello-fn))}))

Ivar Refsdal09:05:16

Yes, I did, and thanks again. I think the easiness of using that style is about the same as the example in the documentation that uses quote

Ivar Refsdal11:05:13

Here is my take on this: https://github.com/ivarref/gen-fn Feedback is appreciated 🙂 CC @U3ZUC5M0R @U060QM7AA

👀 1