ConceptsData & records

Data & records

Most apps keep something: products, bookings, messages, a menu. PhiWebs gives every app its own place to keep them, with no database for you to set up.

Data models

A data model is one kind of record the app keeps — Product, Booking, Message — with its fields. The app’s models are in app/definitions/entities.json. The agent writes them from what you describe; you do not have to.

A field has one of five types:

TypeHolds
textAny text.
numberA number.
booleanYes or no.
dateA date, or a date and time.
relationA link to one record of another model — a booking’s room, an order’s customer.

A record is one entry of a model: one product, one booking.

Records belong to the app. Each published app keeps its records in its own storage, and no other app — not even one in the same workspace — can read them.

Who may create, read, change or delete each model’s records is set by the app’s access rules. See Sign-in & roles.

Records that ship with the app, and records visitors make

There are two kinds of data, and the project keeps them in two places.

Content is data you own and keep changing: the products in a shop, the dishes on a menu, the classes on a schedule. It lives in the project as app/content/<Model>.json, and every page that shows it reads the same model.

Starting records fill a model the first time — a few example entries, or test records for a model your visitors will fill, such as bookings. They live in the project as app/data/<Model>.json.

The difference matters when you publish:

FileWhat happens on every publish
app/content/<Model>.jsonWritten again, every time. Each record is matched by its id, so the project’s version wins over a change made to the same record in the published app.
app/data/<Model>.jsonWritten only while the model is empty. Once the model has records — for example, once visitors have made bookings — these files are left alone, so your visitors’ records are never touched.

So: to change content for good, change it in the project (ask the agent), not only in the published app. A change you make to a content record in the published app is replaced the next time you publish.

Preview records and published records

The preview and the published app have separate records.

  • Preview records are try-out data in the running preview. You and the agent can add, change and delete them freely while you build. They start again from the app’s content and starting records when the preview restarts.
  • Published records are the live data of the published app: what your visitors created, plus the content the project ships.

You can see and edit both in the studio: open the App panel, go to Records, and switch between Preview and Published app. On the published side you edit as the app’s owner, whatever the access rules say.

Data from somewhere else

An app can also read from an outside service you name, such as your own API. That data is not stored in the app, and the app’s access rules do not apply to it; the outside service decides who may see what.

When such a service needs a token, an API key or a password, the app’s Connections (in the studio’s App panel) hold it. The secret never goes into the project’s files: the app sends it on your behalf, and only to the address you bound it to. See Connections.

See also