Databases
Drusite’s databases work as Notion’s do: a database is a page, each row is a page of its own, and views (table, board, calendar, list, gallery) show the rows with their own filter, sorts, grouping and visible properties.
- Database in a page’s
/menu makes one inside the page. - New task board in the sidebar, or Task board in the
/menu, makes a database from the tasks template: Status, Due, Priority and Assignee, with a board to work from. - Open a row to write in it like any page; its properties sit above its text.
Properties
Text, number, select, multi-select, status, date, person, files, checkbox, URL, email, phone, relation, rollup, formula, unique ID, and created and last edited time and person. Properties are named by ID, never by name, so renaming one keeps every value.
- Two-way relations are a pair of properties: one holds the links, the other shows the rows that link to it. Setting either side changes the other, so they can never disagree.
- Computed values (formulas, rollups, created and edited time and person, the mirror side of a relation) are never stored. They’re worked out when a view is shown, so they’re the same on every device and never stale.
Formulas
Drusite has Notion’s formula language (Formulas 2.0): the operators, if/ifs, let/lets,
map/filter/find/some/every with current and index, and the text, number, date, list
and people functions. Empty values behave as Notion’s do (prop("Number") + 1 is 1 when the number
is unset; empty(0) is true), and numbers show to 12 decimal places, as Notion shows them. The
editor refuses what Notion’s refuses, with the reason.
Checked against Notion itself: the results Notion showed for about 120 formulas, on a filled row
and an empty one, are a test. Not supported yet: text colours, links as links, and time zones in
formatDate.
Two devices at once
Every fact in a database is kept on its own, so edits from two devices or two people merge fact by fact: a rename on one and a new value on another both stay; two people adding a tag each keep theirs; two changing one view’s filter and its sort keep both. Two changing the very same value keep the later one.
Version history
A row has the same version history as any page. The database itself has a history of its structure: columns added, renamed, retyped or removed, options, views, rows added and moved to the trash, each listed in words (“Added the column Priority”). Restoring puts back the columns, options and views; a removed row is in the trash, with its own history.
In the Markdown folder and for agents
A database is a folder of rows, each a Markdown file with its values in the frontmatter: see
The Markdown folder. Agents read a database through one of its
views (query_database) and add or change rows by property name (add_row, update_row); see
Agents and MCP.
How they’re stored
For the curious: everything lives in the workspace’s document, so a view is computed without loading any page.
- A database is a page of kind
database; its rows are its subpages. - Its schema is a set of flat keys in its tree entry:
db:p:<property>:name,:kind,:posand:descfor each property,db:o:<property>:<option>for each option, anddb:v:<view>:<field>for each field of each view. Values are JSON. - Each row’s values are keys in the row’s tree entry:
v:<property>for one value, andv:<property>#<item>for each item of a multi-select, relation, people or files value. Who made and last edited a row, and when, arecreatedBy,created,editedByandedited.
Because nothing is a container of its own, two devices can’t each make one and lose the other’s.
crates/drusite-crdt/tests/database.rs checks this, with a property test of three devices editing
at random. The formula engine is crates/drusite-formula; views are computed by
crates/drusite-db.