“Update” (retract + assert)

In Datomic an update retracts the old fact and asserts the new fact.

For convenience, Molecule lets you think in terms of a classical “update” although two operations are performed
in the background. The old fact is still
in the database and available with the time getters.

update

Retract (“delete”)

As mentioned, data is not deleted in Datomic. So it would be outright wrong to say that we “delete” data. Therefore,
Molecule uses the Datomic terminology of “retracting” data which is like saying “this is no longer valid”.
Retracted data is no longer showing up when we query with get but it will be visible with the time getters.

To retract individual attribute values of an entity we apply an empty value and update:

// Retract what Fred likes by applying an empty value
Person(fredId).likes().update
// Fred now doesn't have any preference (but his old preference is still in history)
Person(fred).name.likes$.get.head === ("Fred", None)

retract entity

We can retract an entity (a group of facts with a common entity id) by calling retract on a Long entity id:

fredId.retract
// Fred is retracted from current view (but still in history)
Person(fredId).name.likes.get === Nil