Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Datomic - update cardinality many attr
(ns datomic-update-cardinality-many
(:require [datomic.api :as d]))
(defn update-attr-txs [db entity-id attr values]
(let [current-vals (-> (d/q '[:find [?p ...]
:where [?id :intention/parents ?p]
:in $ ?id]
[added removed] ( (set values) current-vals)]
(concat (->> added
(map #(-> [:db/add entity-id attr %])))
(->> removed
(map #(-> [:db/retract entity-id attr %]))))))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.