This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2024-01-10
Channels
- # announcements (14)
- # beginners (55)
- # calva (4)
- # cider (9)
- # clojure (56)
- # clojure-austin (25)
- # clojure-brasil (1)
- # clojure-dev (29)
- # clojure-europe (44)
- # clojure-mexico (1)
- # clojure-nl (2)
- # clojure-norway (1)
- # clojure-uk (5)
- # clojurescript (15)
- # cursive (9)
- # datomic (5)
- # emacs (30)
- # events (1)
- # graalvm (30)
- # honeysql (17)
- # hyperfiddle (54)
- # introduce-yourself (1)
- # jobs-discuss (6)
- # kaocha (2)
- # leiningen (5)
- # lsp (6)
- # malli (3)
- # missionary (16)
- # off-topic (42)
- # overtone (40)
- # pedestal (2)
- # re-frame (21)
- # shadow-cljs (16)
- # squint (2)
- # tools-deps (14)
With datomic-pro 1.0.6610, we were accidentally passing a (large) map to d/pull like (d/pull db pull-expr large-map)
. Not only did this not explode, it actually caused a memory leak via datomic.db/caching-normalize
, which is a memoize object which was holding on to each large-map.
Hello, I have two attributes that are part of an entity that I’d like to enforce that they get updated together; you shouldn’t be able to update just one by itself. As an example, a person has a legal name, if their legal name changes, I’d like to also enforce a change to :person/name-change-document
that points to another entity that has information about the document that person submitted in order to change their legal name.
(def schema [{:db/ident :person/legal-name
:db/cardinality :db.cardinality/one
:db/valueType :db.type/string}
{:db/ident :person/name-change-document
:db/cardinality :db.cardinality/one
:db/valueType :db.type/ref}])
I’ve tried using https://docs.datomic.com/cloud/schema/schema-reference.html#required-attributes, but this seems to enforce that the entity always has these two values, not that a transaction must specify them both to update an entity. I’ve also thought about using a tuple of [:person/legal-name :person/name-change-document]
but then I found that navigating refs inside tuples is very cumbersome. I’m also aware that this may be possible using ions, but I’d like to find if there’s an alternate way before I delve into creating and maintaining ions.
Is there an idiomatic way in Datomic to enforce this or something like this?Hmm, interesting. I would think that name-change-document
should be its own attribute, with a ref to person entity. Then you have some logic that updates legal-name
as part of the name-change-document transaction. Just some thoughts.
I think you should consider enforcing this check as part of creating the transaction-data server(client) side. Maybe there is some way to ensure this in the transactor, but I think this is more of a business logic concern which therefore should be enforced in the server (not transactor).
Both good points, I was thinking about enforcing it in my business logic, but wanted to explore all options before doing so. Thanks y’all for the input!