This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2022-09-25
Channels
- # announcements (10)
- # babashka (21)
- # calva (8)
- # cider (6)
- # clj-commons (5)
- # clj-kondo (37)
- # cljfx (16)
- # clojure (31)
- # clojure-australia (1)
- # clojure-europe (7)
- # conjure (8)
- # cursive (3)
- # data-science (4)
- # datalevin (6)
- # datomic (18)
- # emacs (10)
- # holy-lambda (3)
- # honeysql (4)
- # humbleui (1)
- # introduce-yourself (1)
- # lsp (13)
- # malli (6)
- # portal (8)
- # scittle (5)
- # specter (1)
- # vscode (9)
- # xtdb (5)
(extend-protocol ccp/Datafiable
Datum
(datafy [^Datum [e a v tx op]] [e a v tx op]))
Has anyone done this work already, a contrib library for Datomic and Datomic Cloud to integrate obvious stuff?i also have a similar utility for testing purposes:
;; FIXME this should be supported more directly by matcher combinators
(defn datum->map [datum]
(into {} (map #(vector % (% datum))) [:e :a :v :tx :added]))
I'm developing a web-based tool that lets Datomic users (both Cloud and Onprem) browse their database. Is there a standard or contributed set of specs to capture Datomic connection strings and configuration data that feels something like shadow-cljs.edn?
i'd be interested in such a tool too... i've also started to develop some puget pretty-printing conveniences for datoms and transaction results, but it's quite clunky, because there are differences between the client configs, eg:
(defn basis-t
"Return the basis T of a db-val, regardless of its concrete implementation."
[db-val]
(or (-> db-val :basisT) ;; (d/client {:server-type :dev-local})
(-> db-val :t) ;; (d/client {:server-type :cloud}) or :ion
))
or
(defn database-id
"Return the database ID of a db-val, regardless of its concrete
implementation."
[db-val]
(let [db-uuid-or-name
(or
;; (d/client {:server-type :dev-local :storage-dir :mem})
(-> db-val :id)
;; (d/client {:server-type :cloud}) or :ion
(-> db-val :database-id))]
(try (medley/uuid db-uuid-or-name)
db-uuid-or-name
(catch Exception _ex
;; (d/client {:server-type :dev-local :storage-dir "/some/path"})
;; Such mode of operation doesn't seem to assign a UUID to databases,
;; so we hard-wire some, based on the name of possible databases.
(-> {"db1" "25f0edda-69ae-4f52-b1b0-3c9ce83ac84e"
"db2" "0f2aa132-c388-4ed7-ba92-3a2710e16965"}
(get db-uuid-or-name))))))
which database-id
we are using to detect db reconstructions, because we store references to db values at a certain point in time in other datomic dbs...how far would this get you
(extend-protocol ccp/Datafiable
Datum
(datafy [^Datum [e a v tx op]] [e a v tx op]))
etc for various internal types and protocols
I still hasn't grasped the essence of datafy & nav, so it hasn't occurred to me to utilize those, but probably quite far. can u recommend any datafy & nav tutorials, besides https://corfield.org/blog/2018/12/03/datafy-nav/ ?
i posted a next journal notebook on reddit showing datafy on java io file
it's quite simple - it's like implementing pr-str on a reference type but instead of printing as a string you're printing as a value
thx, i will dig it up!
im mostly confused by how nav
behaves:
(let [x (datafy {:a 1})]
[(nav x :a 1)
(nav x :a 2)
(nav x :b 1)
(nav x :b 3)
(nav x nil 1)
(nav x nil 2)])
though i should probably do, if i understand nav
correctly:
(let [x (datafy {:a 1})]
[(nav x :a (get x :a))
(nav x :a (get x :a))
(nav x :b (get x :b))
(nav x :b (get x :b))
(nav x nil (get x nil))
(nav x nil (get x nil))])
found your article https://nextjournal.com/dustingetz/datafynav-implementations-for-javaiofile
and the related reddit thread: https://www.reddit.com/r/Clojure/comments/x1ust9/playing_with_datafynav_on_javaiofile_in_a/
nav is unintuitive bc datafy already gave you the k and v, nav is an opportunity to undo the datafy and return the underlying reference. if there is no underlying reference then nav is just weird identity
you're meant to thus bounce between datafy and nav like in the last test in that notebook