Fork me on GitHub

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.


@bhagany: thanks, but that's sad to hear that.


@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 simple_smile


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.


Argh! I know I saw that code fragment somewhere!


Maybe here: Guess I saw something I wanted to see, now what was there, alas.


I guess the option is to use a db function of some sort, or just read in the old values, diff against the new stuff, and assert/retract to taste.