This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2017-11-28
Channels
- # adventofcode (2)
- # bangalore-clj (3)
- # beginners (171)
- # boot (28)
- # chestnut (3)
- # cljs-dev (20)
- # cljsjs (5)
- # clojure (280)
- # clojure-austin (1)
- # clojure-czech (1)
- # clojure-dev (9)
- # clojure-dusseldorf (2)
- # clojure-greece (20)
- # clojure-italy (6)
- # clojure-poland (16)
- # clojure-russia (7)
- # clojure-serbia (4)
- # clojure-sg (1)
- # clojure-spec (18)
- # clojure-uk (153)
- # clojurescript (57)
- # core-async (9)
- # cursive (21)
- # data-science (29)
- # datomic (18)
- # dirac (8)
- # docker (6)
- # duct (1)
- # emacs (50)
- # fulcro (15)
- # hoplon (56)
- # klipse (3)
- # leiningen (14)
- # lumo (1)
- # off-topic (5)
- # onyx (13)
- # other-languages (14)
- # pedestal (1)
- # perun (5)
- # planck (17)
- # re-frame (10)
- # reagent (2)
- # ring (1)
- # spacemacs (51)
- # sql (14)
- # test-check (16)
- # testing (1)
- # unrepl (93)
@lmergen the core idea is to give the option to users for being as specific as they want (i.e. writing migrations one at a time - complex or not) or allowing users to manage one schema and then letting Migrana deal with the migrations
Say, is there a version of :db.fn/retractEntity
that doesn't recur into :db/isComponent true
attributes?
No, but not deleting them doesn't make much sense if they are components. The semantics of being a "component" mean you don't outlive your parent.
Yeah, they aren't really, but they are marked as such in the database and have caused some pretty spectacular cascading deletes
The assumption for components is that (d/datoms db :vaet component-entity-id)
will always show exactly 0 or 1 datom, and the attribute for that datom is :db/isComponent true
Tangentially-related to the last question: let's say I have called retractEntity on entity 123
and I want to undo the transaction. Is it safe to add the data back as [:db.add 123 :attr value]
seqs, or do I need to generate a new tempid and add the data in to the newly-created entity instead?
It's safe. There's some internal counter in datomic that is the max "t" component of all entity ids. If you attempt to assert an id with a "t" component larger than the counter, your transaction will fail.
But since the entity used to have assertions on it, the counter is higher than that, so it will succeed.
Thanks @favila!
Wired/Cool idea about @timgilbert problem
(d/function
'{:lang :clojure :requires [[datomic.api :as d]] :params [db eid]
:code (as-> '[:find ?add ?attr ?comp ?v
:in $ ?e
:where
[(ground :db/add) ?add]
[(ground :db/isComponent) ?comp]
[(ground false) ?v]
[?e ?i]
[?i :db/valueType :db.type/ref]
[?i :db/ident ?attr]] ↓
(d/q ↓ db eid)
(d/with db ↓)
(:db-after ↓)
(d/invoke db :db.fn/retractEntity ↓ eid))})