Pull xform extensions


I’m using datomic on-prem version 1.0.6165 and I’m trying to make use of the xform feature in the pull api. It states specifically that :

The fn is either a fully qualified function allowed under the :xforms key in resources/datomic/extensions.edn , or one of the following built-ins…

But I fail to see an extensions.edn anywhere where I can override. Is this file supposed to be on the transactor’s classpath? The peer server’s classpath? Is there an example anywhere on how to configure it? The documentation seems a bit light :sweat_smile:

Thanks in advance


Since the pull api is only reading data, it means it runs within the peer library, which runs within your application, so the mentioned datomic/extension.edn should be on your application’s classpath, assuming resources/ is specified in the :paths key of your application’s deps.edn.

(I haven’t tried it yet, but that’s my understanding.)

I just tried it quickly:

mkdir -p ~/lab/datomic-xform/{resources/datomic,src/my}
cd ~/lab/datomic-xform
echo '(ns my.custom) (defn xform [x] (str "xformed: " x))' > src/my/custom.clj
echo '{:xforms [my.custom/xform]}' > resources/datomic/extensions.edn
time clj -Sdeps '
{:paths ["src" "resources"]
 :deps {com.datomic/datomic-pro {:mvn/version "1.0.6165"}}
 :mvn/repos {"my.datomic.com" {:url "https://my.datomic.com/repo"}}}' -e "
(require '[datomic.api :as d])
(def uri \"datomic:mem://x\")
(d/create-database uri)
(d/pull (d/db (d/connect uri))
        '[[:db/ident :xform my.custom/xform]]
#:db{:ident "xformed: :db/doc"}
clj -Sdeps  -e   5.95s user 0.33s system 208% cpu 3.006 total

For the record, this is how the program fails if the function is not allowed from the extensions.edn:

echo '{:xforms [my.custom/disable-xform]}' > resources/datomic/extensions.edn
time clj ...
Execution error (ExceptionInfo) at datomic.extension-resolver/anomaly! (extension_resolver.clj:24).
'my.custom/xform' is not allowed by datomic/extensions.edn

Full report at:
clj -Sdeps  -e   8.71s user 0.42s system 272% cpu 3.347 total

Thanks! This probably requires a bit more documentation though :wink: