This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2022-04-30
Channels
- # announcements (5)
- # babashka (9)
- # beginners (48)
- # calva (300)
- # clj-kondo (9)
- # clojure (44)
- # clojure-austin (2)
- # clojure-europe (14)
- # clojure-uk (4)
- # clojurescript (1)
- # conjure (2)
- # datascript (3)
- # datomic (8)
- # exercism (5)
- # fulcro (1)
- # luminus (4)
- # music (1)
- # off-topic (12)
- # pathom (2)
- # rdf (18)
- # react (8)
- # sci (78)
- # shadow-cljs (12)
- # spacemacs (4)
- # tools-build (5)
- # tools-deps (26)
- # vim (4)
- # xtdb (8)
A simplified example of my data model to illustrate the behaviour I need:
(def schema
{:uuid {:db/unique :db.unique/identity}
:children {:db/valueType :db.type/ref
:db/cardinality :db.cardinality/many
:db/isComponent true}
:wraps {:db/valueType :db.type/ref
:db/isComponent true}})
(def conn (d/create-conn schema))
(d/transact! conn
[{:uuid 1 :children [{:uuid 2}]}
{:uuid 3 :wraps {:uuid 2}}])
(d/transact! conn [[:db.fn/retractEntity [:uuid 1]]])
What I would like to happen is retractEntity
to detect 2
is also a component of 3
and consequently retract 1
without retracting 2
. I'm not sure it would make sense for DataScript to have this behaviour by default, so I'm not suggesting that. Rather I'm trying to determine whether there is a way to get this behaviour without writing my own custom retractEntity
? (This example is simple, but I'm usually dealing with large trees, so I prefer to fall back on existing facilities if at all possible.)I cant see a way to do this with retractEntity. I think you will have to write a custom logic for this one.