Publishing and open fields

Drafts, posts that wait for approval, and fields readers can change.

Drafts on public collections

On public_read and community, { published: false } saves a draft the public can't see, enforced by the server. The author still sees their own; your dashboard shows every draft.

const post = await notes.create({ title: "wip" }, { published: false })  // hidden
await notes.update(post.id, {}, { published: true })                     // now live

post.published   // top-level boolean, beside id — not post.data.published

Never fake drafts with a status field + client-side filtering on a public collection; the data still reaches every reader's network tab. published is an option, not a data field; the server rejects it inside data.

Posts that wait for approval

A community collection can hold every post until you approve it. It is a setting on the safety rule, in plain words, in gemmein/collections/<name>.json or under Publishing on the collection's page in the dashboard's Data:

{ "rule": "community", "means": "reviews, approved before they show", "publishing": "owner approves" }
  • "authors publish" is the default, and what a collection with no setting does.
  • With "owner approves", a person's post is saved as a draft only its author sees. A person's { published: true } on create or update is 403 moderation_required.
  • You publish from a collection's own Records tab; Data shows how many posts wait. Your server can publish with a secret key, and a relay can too.
  • You can't change the rule of a collection while posts wait (409 posts_waiting): approve or delete them, or turn the setting off, first.
  • An author's change to an approved post returns it to waiting (a save that changes nothing keeps the approval), and Data counts it among the posts waiting ("new or edited after approval"). Unpublishing your own post is always allowed.
  • The setting works on community. On public_read it is refused: only you write there, so there is nothing to approve. Anywhere else, and for any other value, gemmein dev and gemmein sync refuse it before anything changes (invalid_publishing).
  • A relay's data_change trigger takes published: false to tell you each time a post starts waiting.

Fields readers can change

Every record is its author's to edit. For likes, votes, RSVPs, "accept" or "mark as read", name the fields other readers may change under "openFields" in gemmein/collections/<name>.json, or under Open fields on the dashboard's collection's page in Data. Each field gets one operation, and every other field stays its author's. With no openFields, the default, only the author changes anything.

{ "rule": "community", "openFields": { "likes": "count once per person", "status": { "one of": ["accepted", "declined"] }, "read": "per person flag" } }
OperationWhat it doesCall
"count once per person"A number each person adds 1 to once and can take back. The total is record.data.likes, never below 0; the same person twice counts onceopen(id).count("likes", 1), count("likes", -1)
{ "one of": [...] }A choice from the list (up to 50) that any signed-in person who reads the record may set; the last one set winsopen(id).set("status", "accepted")
"per person flag"Each person's own yes or no, which only they see in record.mine; the record itself never changes. Your dashboard and a secret key read who set it in record.flaggedByopen(id).flag("read", true)
"one per person of"A poll or an RSVP: "rsvp": "one per person of yes, maybe, no" (or { "one per person of": [...] } when a choice holds a comma), on a field declared { "type": "json" }. Each person holds one choice, and can change or withdraw it. The record counts each choice, record.data.rsvp → { yes: 3, maybe: 1, no: 0 } in the listed order, and record.mine.rsvp is your choice or nullopen(id).choose("rsvp", "maybe"), choose("rsvp", null) to withdraw
  • Open fields work on shared, community, public_read, addressed and direct, up to 10 per collection. On private and admin_write nobody else reads the records, so gemmein dev and gemmein sync refuse them (invalid_open_fields). On app_only no app session reads them at all, so they are refused there too.
  • record.mine holds your own marks ({ likes: true, read: false, rsvp: "yes" }), so the app can show a filled heart.
  • When many people choose at once, each person holds exactly one choice and the counts equal the choices held. A choice outside the list is 400 open_value_not_in_list, naming the choices. When a person's account is deleted, their choice stays in the counts as an anonymous number, as a like does.
  • When a choice is taken off the list, people who hold it keep it: record.mine.rsvp still says it and record.mineRetired.rsvp is true. record.data.rsvp counts only the listed choices, and choosing the retired one again is 400 open_value_not_in_list. Putting it back on the list brings its count back.
  • A change to an open field never moves record.version, and never sends an approved post back to waiting.
  • A person signed in to your app changes open fields only through open(id); writing one in create() or update() is 400 open_field_write. Your server (a secret key) and your dashboard may set a "one of" field in create() or update(), to a listed choice or null; any other value is 400 open_value_not_in_list. Counters, per person flags and "one per person of" choices change only through open(id), for everyone. See Errors for the rest.

Fields only the business can change

The opposite of an open field: a status your AI should never let a member set on their own booking. Name the field and its starting value under "lockedFields" in gemmein/collections/<name>.json. Nobody using the app may ever name a locked field in create() or update(), whatever its value, even the field's own default — not a signed-in member, a visitor, or the founder signed in to their own app. Naming it is enough to be refused, as 403 field_locked. A create that leaves it out is born with the default already written: a real stored value from the start, not a fill a reader sees later.

{ "rule": "private", "lockedFields": { "status": "requested" } }
  • Only the business side ever sets or changes one: your server (a secret key), a relay, an Edge function, a view's move action, or the dashboard. Reads are unchanged — the person still reads their own status.
  • Works on private, shared, community and direct, the rules a member ever writes a record on, up to 10 fields. Named on admin_write, public_read, addressed or app_only, where nobody using the app writes a record at all, it is refused (400 invalid_locked_fields): locking a field there would do nothing.
  • A locked field's default is text, a number or true/false, typed to the field's own declared shape; it must already be declared under "fields", and a field can't be both open and locked. All refused as 400 invalid_locked_fields, by gemmein dev, npx gemmein sync and the dashboard's collection settings, before anything changes.
  • A relay's data_change trigger can filter on the locked default (where: { status: "requested" }) and fire the moment a record is created, because the value is really in the row from the start.
Was this page helpful?

Last updated