Is it possible to retract and add data in one transaction?
I know that by adding new data to a attribute with single cardinality, it will automatically replaces the old one. It does this by retracting and adding.
However sometime, I just want to retract a existing value from a single cardinality and then remove some values from a multiply cardinality attribute.
Can this be done in Java?
I only see example of doing it with two different transaction.
One is a list of map for adding.
Another is a list of a list for retracting.
My guess in Java it would be.
List transactionList = new List<>();
transactionList.add(Util.list(":db/retract", 123L, “:community/category”, “news”") );
transactionList.add(Util.list(":db/retract", 123L, “:community/category”, “traffic”") );
transactionList.add(Util.list(":db/add", 123L, “:community/category”, “blog”") );
Looks okay but you might find it easier to use some syntax sugar for data structure literals. I haven’t done datomic from java, so take with grain of salt