Skip to content

create_table

Gives the site a table of its own: a named set of fields, and somewhere to put the rows. Typed inside bash, where help create_table prints the same.

Usage: create_table HANDLE FIELDS [options]
Gives the site a table of its own: a named set of fields, and somewhere
to put the rows. This is how a contact form gets somewhere to send
what a visitor types. It writes tables/<handle>.json on `branch`, and
merge_branch makes the table. Read `vzk/tables` first.
A reserved handle must keep what its screen reads, and may
add anything else:
The owner's Enquiries screen reads `enquiries`. It must keep at least one field of the site's choice, and it must stay `readable_by: owner` (it holds what strangers send).
The owner's Posts screen reads `posts`. It must keep `title` (text, what the post is called, in the tab and on a shared link) and `body` (markdown, the post itself), and it must stay `readable_by: public` (its records are pages of the site). By default, rows wait for a published_at date; publication is configurable.
The owner's Portfolio screen reads `portfolio`. It must keep `title` (text, the item's name), `summary` (long_text, a line about the item), `cover` (picture, the item's picture), `body` (markdown, the item's story), and `position` (number, its place in the owner's order), and it must stay `readable_by: public` (its records are pages of the site). By default, rows wait for a published_at date; publication is configurable.
`invoices`, `invoice_lines`, `invoice_payments`, and `invoice_details` are the tables Payments sets up for itself. Leave those handles to it.
Options:
--handle TEXT (required)
A lowercase handle, such as "enquiries". This is what a `<form table="…">` names and what the submission path carries. `vizitka` is the platform's own and is refused; the reserved handles in this tool's description are yours to use and must keep their screen's shape.
--name TEXT
What the owner sees this table called in the Vizitka app: at most 100 characters, with no line break or other control character.
--fields JSON ... (give the flag again for each) (required)
The shape of one row: a list of fields, in the order a form should ask them, at most 100 of them.
--publication JSON
Which rows may appear publicly. Set field to null for all rows, or name a declared date field (today or earlier) or boolean field (true). Null restores the default: posts and portfolio use published_at; other tables show all rows. Changes are live at once without editing rows. Table read access still applies.
--keep TEXT
How long the table keeps a row, as a whole number of days from 1 to 36500: "90 days" or "1 day". Rows older than that, counted from the day each was added, are removed from the table once a day, never sooner than a day after the setting is saved or changed, and cannot be brought back by the owner or by an agent, so ask the owner before setting it. Taken only for a table that is `readable_by: public`: any other's is the owner's to set, and the Vizitka app cannot set it yet. Null keeps every row, which is the default.
--writable_by owner|public
Who may add a row. `public` is what lets a visitor submit a form. Default `owner`.
--readable_by owner|public
Who may read a row. `owner` keeps it off the site entirely and is the right answer for anything a stranger sends. `public` lets a page list the rows, and is what a table needs before it can have a page of its own (pages/<path>/[slug].vzk). Default `owner`.
--branch TEXT
The branch to write tables/<handle>.json on, made with `git switch -c`.
--message TEXT
What the change is, in a line. Defaults to naming the files.
--json OBJECT
Every argument at once, as one JSON object; --json - reads it from stdin.