This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2015-10-28
Channels
- # aws (3)
- # beginners (14)
- # boot (222)
- # cider (9)
- # cljs-dev (14)
- # clojure (107)
- # clojure-chicago (1)
- # clojure-dev (31)
- # clojure-nl (1)
- # clojure-poland (3)
- # clojure-russia (44)
- # clojure-sg (13)
- # clojure-za (3)
- # clojurescript (81)
- # core-async (5)
- # core-logic (4)
- # cursive (3)
- # data-science (3)
- # datomic (13)
- # events (7)
- # ldnclj (6)
- # leiningen (1)
- # off-topic (4)
- # om (298)
- # re-frame (13)
- # ring-swagger (7)
- # yada (12)
Hi all. I was trying to update value of isComponent ref with new set of data, is there a idiomatic way to do that? Updating ref with new values in map transaction just adding them to the set.
@wambat: I'm pretty sure you have to explicitly retract the elements in the old set, if you want to replace them.
@wambat one strategy for this would be to define a cas-like transaction function that operates with logic: “if card/many attr on this entity still has the same set of values, retract that set and assert this new set"
but yeah, cardinality one will handle retractions of old data w/assertions of new but card many will add new assertions unless you supply retractions.
I'll try adding the function, thanks @bkamphaus .
@bkamphaus: I think I figured out a solution that avoids the complications and any potential problems I might have had with 'with'. Thanks for your help. :)
@domkm good to hear! If it’s something you end up sharing let me know, I’ll be curious to see what solution you settled on
I’ve got an attribute :event/attendees :ref :many isComponent
and I want to replace it with a new set of values. I tried (in a tx) :event/attendees #{ … new entity ids … }
, but it just adds the new ones without auto-retracting the old. Is there an explanation of how that should work?
I thought I saw an example out there where you could just assert the value of a component attribute and if the value is of type set
it would do the right thing.
Maybe here: http://docs.datomic.com/transactions.html#cardinality-many-transactions. Guess I saw something I wanted to see, now what was there, alas.