- Jinaga Concepts
Deletion
Facts are immutable, so you cannot really delete them.
Instead, you can create a new fact that marks its predecessor as deleted.
[FactType("Construction.Project.Deleted")]
public record ProjectDeleted(Project project, DateTime deletedAt);
var projectADeleted = await j.Fact(new ProjectDeleted(projectA, DateTime.UtcNow));
On its own, this fact does not do anything.
ImmutableList<Project> projects = await j.Query(projectsCreatedByUser, user);
But if you include it in the specification, it will filter out the predecessor from the results.
var projectsCreatedByUser = Given<User>.Match(u =>
u.Successors().OfType<Project>(p => p.creator)
.Where(p => !p.Successors().OfType<ProjectDeleted>(d => d.project).Any())
);
ImmutableList<Project> projects = await j.Query(projectsCreatedByUser, user);
Now if you are really concerned about facts never being truly deleted, there is a way to purge unreachable facts.
We'll save that for later.
Continue With
Restore