Retract and adding new data in 1 transaction

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.


[[:db/retract 123 :community/category "news"]
 [:db/retract 123 :community/category "traffic"]
 [:db/add 123 :community/category "blog"]]

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”") );

Does this look right?


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