WebRobot

Designing an app · Lesson 2

Data: whose is each record

Pages show data, agents read and write it, triggers react to it: almost every rule of an app is a rule about data. Two decisions carry most of the weight: who owns a collection’s records (ownedBy), and which other roles reach them (access). Here you see their effect on six people, one cell at a time.

Use Next, or the ← → keys. You can also change ownedBy and the lawyers’ rule yourself: the matrix is recomputed with the runtime’s own rule, and the validator checks the result.

The rule, in four lines

  1. Admins reach everything. Whoever has the role given by admin_emails reads and writes every record of every collection.
  2. shared and app: everyone reads. Writing stays with the admins (shared) or with the app’s agents through their tools (app).
  3. user and instance: the owner. The person whose id the runtime stamped on the record when it was created.
  4. Then the access rules. A role, an optional where on the record’s fields ({user.email}, {user.id} stand for the person), and can: read, or read and write. Nothing else reaches a record.

Fields: what a record is made of

Each collection declares its fields. The type decides the input on the form, how the value is checked and normalised, and how it is shown.

On any field: required, default, help, visibleWhen (shown only if another field has a value), roles (only some roles see it — like the assigned lawyer above, which only the owner sets), gatedBy (unlocked by a plan).

The other properties of a collection

Roles that come from the data

A role can be derived from a record: assignedBy: derived, from: collection:practices.manager_email. Whoever’s email is in that field holds the role, for as long as it stays there. Combined with where, it gives each practice manager their own practice, without anyone handing out roles by hand.

Names you cannot use

users, login_tokens, sessions, credentials, runs, approvals, files and a few others are the runtime’s own data. A manifest can never declare, show or give a tool over them: reading login_tokens would be an account takeover.

What to take away

Next

Lesson 3 is about the pages: how tables, cards, KPIs and charts show these records, and how a landing page is made of blocks.

Lesson 3: Pages, views over the data →

← The whole path