This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2021-04-14
Channels
- # babashka (53)
- # beginners (158)
- # calva (25)
- # cider (21)
- # clara (1)
- # clj-kondo (12)
- # cljsrn (6)
- # clojure (94)
- # clojure-australia (2)
- # clojure-bay-area (6)
- # clojure-europe (40)
- # clojure-nl (10)
- # clojure-spec (16)
- # clojure-uk (18)
- # clojurescript (95)
- # cursive (14)
- # data-science (1)
- # datascript (6)
- # datomic (18)
- # depstar (2)
- # duct (36)
- # emacs (15)
- # events (4)
- # fulcro (16)
- # graalvm (10)
- # helix (25)
- # honeysql (6)
- # jackdaw (4)
- # jobs (2)
- # leiningen (24)
- # lsp (4)
- # malli (10)
- # off-topic (3)
- # pathom (3)
- # polylith (19)
- # practicalli (4)
- # prelude (1)
- # re-frame (6)
- # reagent (13)
- # reitit (3)
- # remote-jobs (10)
- # ring (12)
- # ring-swagger (2)
- # shadow-cljs (54)
- # testing (17)
- # tools-deps (10)
- # xtdb (14)
has there been any news on cloud disaster recovery, the discussions don’t seem active https://forum.datomic.com/t/cloud-backups-recovery/370/10 we currently have a hand rolled tx log backup/restore solution but it’s a bit painful to maintain
Maybe you're aware already but there's a feature request on ask.datomic: https://ask.datomic.com/index.php/431/cloud-backup-and-recovery
The recommendation for enums in Datomic is to https://docs.datomic.com/cloud/schema/schema-modeling.html#enums. Using :db/ident
as an enum value complicates the use with d/pull
. Everywhere you pull an entity, you'll need to write code to deal with the nested enum entity. For example, say I have a :user/type
enum that is defined as suggested by that doc (card one, ref attr). Anytime I pull my :user/type
attribute, I need to write code to unnest the :user/type
value.
(d/pull (d/db conn) '[:user/type] [:user/id "a"])
=> #:user{:type #:db{:id 87960930222153, :ident :user.type/a}}
How are folks dealing with this? Just always wrapping the d/pull return with something like (update :user/type :db/ident)
? Perhaps always remembering to specify the pull pattern for all enum attributes as (:user/type :xform my-ns/get-db-ident)
, where my-ns/get-db-ident
is just (def get-db-ident :db/ident)
?one way i was doing this was to take my nested entity thats returned from the pull and then run it through a post-walk like so:
(clojure.walk/postwalk
#(match %
{:db/ident ident} ident
:else %)
nested-entity)
if you know that all maps with db/ident
are referencing enums you want to unwrapAt work we tried both suggestions, and switched from the postwalk approach to the xforms. Mostly because of performance. We tend to def our pull expressions for re-use, so the xforms are in 1 place. Needing to remember it's a db/ident isn't much of a problem for us, it's required to pull db/ident anyway. But one could always write a linter make sure that xforms is used for idents.
We had a specific usecase where we had very big resultsets (~150,000 entities + nesting). That's when we replaced the postwalk. Generally it's fine for sure.
that is a big result, out of curiosity, how much was the difference between walk and xform with that result?
To give a very rough idea about our postwalk approach vs a direct update fn;
(time
(do (map (fn [x] (update x :field :db/ident))
corpus)
nil))
"Elapsed time: 0.093924 msecs"
=> nil
(time
(do (walk/postwalk (fn [x]
(if (and (map? x)
(:db/ident x))
(:db/ident x)
x))
corpus)
nil))
"Elapsed time: 552.667018 msecs"
=> nil
(corpus is a list of 150,000 maps btw)(time
(do (mapv (fn [x] (update x :field :db/ident))
corpus)
nil))
"Elapsed time: 142.214586 msecs"
=> nil
For completionist sake:Thought I'd persist this question on ask.datomic so others can reference it and add their opinion: https://ask.datomic.com/index.php/606/recommended-way-to-handle-db-ident-enums-when-used-with-pull