Fork me on GitHub
Ivar Refsdal08:05:51

How do people write database functions (on prem)? Using quote (`'`) as per the 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


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.


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.


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


@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: Feedback is appreciated 🙂 CC @U3ZUC5M0R @U060QM7AA

👀 1