This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2021-02-12
Channels
- # babashka (22)
- # beginners (112)
- # calva (7)
- # cider (2)
- # clj-kondo (43)
- # cljdoc (25)
- # cljsrn (30)
- # clojars (16)
- # clojure (73)
- # clojure-australia (2)
- # clojure-bay-area (8)
- # clojure-europe (16)
- # clojure-finland (1)
- # clojure-italy (2)
- # clojure-nl (7)
- # clojure-uk (9)
- # clojurescript (28)
- # clojureverse-ops (2)
- # conjure (2)
- # css (22)
- # cursive (28)
- # datomic (9)
- # depstar (28)
- # emacs (6)
- # fulcro (39)
- # graalvm (61)
- # honeysql (38)
- # instaparse (3)
- # jobs (1)
- # kaocha (3)
- # malli (7)
- # pathom (83)
- # sql (3)
- # tools-deps (18)
- # vim (2)
- # xtdb (15)
just understood that I can get connection from entity using such approach
(defn entity-conn [entity]
(-> entity d/entity-db :id d/connect))
what are downsides of that? The idea is to pass either db or entity instead of passing connection to functions which performs changesI believe that as long as you're aware that it is only connecting to a named db, not considering it's point in time, you'll be ok. You may just encounter an overhead by constantly connecting to you datomic system
Don’t do this evar 🙂. 1) :id is private 2) :id isn’t always a connection string. I doubt this works for in-memory dbs. 3) not getting a connection is liberating because now you know a whole tree of function calls can’t mutate the db. If you do this, you can no longer enjoy that feeling. 4) using entity-db already assumes that the function is getting an entity instead of an equivalent map. This is soapbox territory: IMO, d/entity, while convenient and cool, was a mistake because it makes it very easy to lose track of dependencies in large codebases over the long-term (i.e. what does this tree of functions need to read to do its job). Prefer d/pull for new development, which makes that explicit and also eases migration to cloud if you ever do that in the future.
This also breaks the “use a consistent db value for a unit of work” best practice: https://docs.datomic.com/on-prem/best-practices.html#consistent-db-value-for-unit-of-work
we did something similar to this at a previous job. I built a type that would record the different access to entity so we could create a pull at the top of the chain that would supply all of the necessary values below. was quite fun but the migration was still kinda scary. its not a great place to be and you will have to remove (or will desperately want to remove) all of this stuff at some point in the future
btw link to Log API doesn't work https://docs.datomic.com/log.html link is placed here https://docs.datomic.com/on-prem/best-practices.html#use-log-api
probably it should be https://docs.datomic.com/on-prem/api/log.html