Facts are not truly deleted. You indicate that they should be deleted by introducing a new fact. There are mechanisms for taking them out of storage, but we'll cover those later.
To indicate that a site should be deleted, define a fact that refers to the site as a predecessor. It also should have a timestamp so that we can differentiate one deletion from another.
[FactType("Blog.Site.Deleted")]
public record SiteDeleted(Site site, DateTime deletedAt) { }
Renderer.RenderTypes(typeof(SiteDeleted))
To indicate that a site should be deleted, create an instance of that fact.
var siteDeleted = await jinagaClient.Fact(new SiteDeleted(site, DateTime.UtcNow));
jinagaClient.RenderFacts(siteDeleted)
If you query the specification now, you will still see the site.
sites = await jinagaClient.Query(sitesByUser, user);
sites.Count()
1
That's because we need to change the specification to exclude deleted sites. Add a clause that filters out sites that have a site deleted successor.
sitesByUser = Given<User>.Match((user, facts) =>
from site in facts.OfType<Site>()
where site.creator == user
// Include only the sites that have not been deleted
where !facts.Any<SiteDeleted>(sd => sd.site == site)
select site);
sites = await jinagaClient.Query(sitesByUser, user);
sites.Count()
0