Top-Level Facts

Every Jinaga model is going to start with a top-level fact owned by the user. This is how we give each user their own set of data. Don't worry; users will be able to share facts with one another. This is just the starting point.

Express a Jinaga model as a set of C# records representing historical facts. Decorate each record with a FactType attribute. The fields of the records are predecessors -- facts that came before -- and fields.

We will be modeling a content management application called Blog. In the Blog model, a site is an entity created by a specific user. We use the date and time to distinguish it from other sites that the user created. The assumption is that a user will not create multiple sites within the same millisecond.

Notice that the site does not contain any other properties, such as a title or a domain name. Those properties are mutable, and therefore not part of the initial fact.

[FactType("Blog.Site")]
public record Site(User creator, DateTime createdAt) { }

The User type is provided by the Jinaga library. It represents someone who can log into the app. A model almost always starts with a fact owned by a user. This gives us a place to start our authorization rules.

In a Polyglot Notebook, your code can generate output. If the last line of your code block does not end in a semicolon, then it is treated as an output expression. It is evaluated and the results are displayed.

Use the Renderer.RenderTypes method to display a graph of your model. Pass the typeof each of the types you want to document in the graph.

// Call RenderTypes without a semicolon to display the graph
Renderer.RenderTypes(typeof(User), typeof(Site))

It will produce the following graph:

%0 Blog.Site Blog.Site Jinaga.User Jinaga.User Blog.Site->Jinaga.User creator

See Also

Jinaga is a product of Jinaga LLC.

Michael L Perry, President