Additional Mutable Properties

To add mutable properties to the model, keep defining new facts. Add them to the projection to get a complete picture of your entities.

[FactType("Blog.Site.Domain")]
public record SiteDomain(Site site, string value, SiteDomain[] prior) { }

Renderer.RenderTypes(typeof(SiteDomain), typeof(SiteName))
%0 Blog.Site.Domain Blog.Site.Domain Blog.Site.Domain->Blog.Site.Domain prior Blog.Site Blog.Site Blog.Site.Domain->Blog.Site site Jinaga.User Jinaga.User Blog.Site->Jinaga.User creator Blog.Site.Name Blog.Site.Name Blog.Site.Name->Blog.Site site Blog.Site.Name->Blog.Site.Name prior
var siteDomain0 = await jinagaClient.Fact(new SiteDomain(site, "example.com", []));

jinagaClient.RenderFacts(siteDomain0, siteName2)
%0 eLG0D2gojV+51Ix80JNo2Uh4EQTKvjbZUq5JNrf9K5gSXEqRmi7LBSleOl09F/bWdrlWUgDkalEH847v83U7fA== Jinaga.User publicKey --- FAKE USER --- fRStq94kRaFpm+n+5BCGNRP7e7NOyihLThCOo0vRo+inA0LbPUbVkJsNJwcWCKIVb9lUylMwc7Bt2vfHTbicPg== Blog.Site createdAt 2024-05-18T20:32:02.... fRStq94kRaFpm+n+5BCGNRP7e7NOyihLThCOo0vRo+inA0LbPUbVkJsNJwcWCKIVb9lUylMwc7Bt2vfHTbicPg==->eLG0D2gojV+51Ix80JNo2Uh4EQTKvjbZUq5JNrf9K5gSXEqRmi7LBSleOl09F/bWdrlWUgDkalEH847v83U7fA== creator kAbzPMz4AjywxsODbiFgJVtYg5DRQIFAUFr+FjvmGYK3IrJdlSr8qVqGsxSXOOgMz/92txw2uJXuQW/Z5KOwyQ== Blog.Site.Domain value example.com kAbzPMz4AjywxsODbiFgJVtYg5DRQIFAUFr+FjvmGYK3IrJdlSr8qVqGsxSXOOgMz/92txw2uJXuQW/Z5KOwyQ==->fRStq94kRaFpm+n+5BCGNRP7e7NOyihLThCOo0vRo+inA0LbPUbVkJsNJwcWCKIVb9lUylMwc7Bt2vfHTbicPg== site Ks00prnUjVMTiazHRnLzVWWuurH0Xc2djtNbTz93TW9svgXu/GNCVq+XV2daZYpv2GZtJGyP+W6AmrITEZMjeA== Blog.Site.Name value My Site Ks00prnUjVMTiazHRnLzVWWuurH0Xc2djtNbTz93TW9svgXu/GNCVq+XV2daZYpv2GZtJGyP+W6AmrITEZMjeA==->fRStq94kRaFpm+n+5BCGNRP7e7NOyihLThCOo0vRo+inA0LbPUbVkJsNJwcWCKIVb9lUylMwc7Bt2vfHTbicPg== site 4xLWBu6uW4rV5faLluXmKSSwfTHzGN4um6W8+FbrZM4F67vHlXz2j/z3+1adGVxtzSIurTtHoOwcX8vT/HDxww== Blog.Site.Name value My Blog 4xLWBu6uW4rV5faLluXmKSSwfTHzGN4um6W8+FbrZM4F67vHlXz2j/z3+1adGVxtzSIurTtHoOwcX8vT/HDxww==->fRStq94kRaFpm+n+5BCGNRP7e7NOyihLThCOo0vRo+inA0LbPUbVkJsNJwcWCKIVb9lUylMwc7Bt2vfHTbicPg== site 4xLWBu6uW4rV5faLluXmKSSwfTHzGN4um6W8+FbrZM4F67vHlXz2j/z3+1adGVxtzSIurTtHoOwcX8vT/HDxww==->Ks00prnUjVMTiazHRnLzVWWuurH0Xc2djtNbTz93TW9svgXu/GNCVq+XV2daZYpv2GZtJGyP+W6AmrITEZMjeA== prior y4JvMVeVi8615eRRaFgAvebiJTq5M71SNju8TfQfaP0mInGfxJV5dpACeWQdt2P01LwXmBxlxmS9pQoowEMFMw== Blog.Site.Name value My Journal y4JvMVeVi8615eRRaFgAvebiJTq5M71SNju8TfQfaP0mInGfxJV5dpACeWQdt2P01LwXmBxlxmS9pQoowEMFMw==->fRStq94kRaFpm+n+5BCGNRP7e7NOyihLThCOo0vRo+inA0LbPUbVkJsNJwcWCKIVb9lUylMwc7Bt2vfHTbicPg== site y4JvMVeVi8615eRRaFgAvebiJTq5M71SNju8TfQfaP0mInGfxJV5dpACeWQdt2P01LwXmBxlxmS9pQoowEMFMw==->4xLWBu6uW4rV5faLluXmKSSwfTHzGN4um6W8+FbrZM4F67vHlXz2j/z3+1adGVxtzSIurTtHoOwcX8vT/HDxww== prior
var sitesByUser = Given<User>.Match((user, facts) =>
    from site in facts.OfType<Site>()
    where site.creator == user
    where !facts.Any<SiteDeleted>(
        sd => sd.site == site &&
        !facts.Any<SiteRestored>(sr => sr.deleted == sd))
    select new
    {
        Site = site,
        Names =
            from name in facts.OfType<SiteName>()
            where name.site == site
            where !facts.Any<SiteName>(next => next.prior.Contains(name))
            select name.value,
        Domains =
            from domain in facts.OfType<SiteDomain>()
            where domain.site == site
            where !facts.Any<SiteDomain>(next => next.prior.Contains(domain))
            select domain.value
    });

var sites = await jinagaClient.Query(sitesByUser, user);

var sitesViewModel = sites.Select(s => new
{
    Name = s.Names.FirstOrDefault() ?? "New site",
    Domain = s.Domains.FirstOrDefault() ?? ""
});

sitesViewModel

Continue With

Hierarchy

Jinaga is a product of Jinaga LLC.

Michael L Perry, President