Skip to content

update_record

Replaces what one row holds. Typed inside bash, where help update_record prints the same.

Usage: update_record HANDLE SLUG VALUES [options]
Replaces what one row holds. `values` is sent **whole**, so a field
you leave out is dropped: read the row with `get_record`, change the
part you mean to change, and send it all back. Sending only a title
is how a post loses its body. A `secret` field is the exception: left
out, or sent back as `get_record` shows it, it keeps what it holds.
**There is no draft.** An edit to a published row is on the site as
this returns; `replaced` in the answer is what to send back if it was
wrong. The table's publication rule decides whether the changed row
stays public: all rows, a date that has come, or a boolean that is true.
Leaving a configured publication field out takes the row off the site.
There is no rename: the slug is
the row's address and nothing writes a redirect.
Options:
--handle TEXT (required)
Public table handle from get_site.
--slug TEXT (required)
Row slug from list_records: its address's last segment.
--language TEXT
Row language, where rows share a slug.
--values JSON (required)
The row's own values, keyed by the field names its table declares: { "title": "How I light a winter wedding", "body": "…markdown…" }. Checked against the definition and cut down to it, so a key the table does not name is dropped, a value of another type is cast to what the field holds (5 under a text field is stored as "5"), and one the type refuses even then comes back as a sentence naming the field. A field pointing at rows takes the `tenant_record_id` list_records shows for each: 14, or [3, 7] where it holds a list. Replaces what the row holds, so send the whole row back.
--json OBJECT
Every argument at once, as one JSON object; --json - reads it from stdin.