Skip to content
Open Saka

Stored data

A Flow computes its result each time you read it. Stored data stays in the database until you change it.

var stores data you can change, and val stores data that never changes. Both need a contract:

var visits! num = 0
val founded! num = 2026
var tags* str = {"new", "sale"}
var stock* str -> num = {"pen" -> 12, "book" -> 3} #[unique = .k]

stock maps each item to how many are in stock. #[unique = .k] lets each key appear once, so an item has one count. A key also makes a lookup by it fast: the database finds the Values with that key without reading the rest.

Flows read the current data:

def twice_visits = visits * 2
twice_visits // {0}

A role describes a kind of thing, such as a book. Its properties hold each member’s data:

role Book
prop Book::title! str
prop Book::pages! num
prop Book::author? str

Each Book has exactly one title and one page count, and at most one author.

Book reads every member of the role, and .title reads their titles:

Book.title // str:{}

There are no Books yet. The app’s Views sidebar now lists a Book view, with a row for each Book and a column for each property. The next page adds Books.