useMongocampDrafts
The drafts workflow of a collection declared with drafts (server 2.11). Needs the write grant (and the collection's update rule).
ts
const { publish, unpublish, discardDraft, run } = useMongocampDrafts()
await publish('articles', id) // the working copy becomes the published state
await unpublish('articles', id) // a draft again — readers no longer see it
await discardDraft('articles', id) // drop the pending changes (400 when there are none)
await run('publish', 'articles', id) // one of the three by name (`DraftAction`)Publishing is validated like a write and sets _status: 'published', publishedAt, publishedBy; publishing again is harmless. Each action is audited (publish, unpublish, discardDraft — see useMongocampHistory). A collection without drafts answers 400, a missing document 404; every call rejects on failure (15 s timeout) — useMongocampError().describeServerError shows the server's text.
Reading the working copies is drafts: true on a read (see MongocampCollectionData's Drafts switch); draftStateOf in utils/declaration.ts tells draft / published / changed.