method
BoundTypedCollection.SaveDraft
Stage incomplete edits without replacing a document's published snapshot.
Example
pages := generated.PagesCollection.With(app.Local())
saved, err := pages.SaveDraft(
ctx, draft.ID,
generated.PageDraft{Title: core.Null[string]()},
core.TypedMutationOptions{
Actor: &session.User,
ActorCollection: session.Collection,
ExpectedRevision: draft.Revision,
},
)
if err != nil {
return err
}
_ = saved.RevisionArguments
| Argument | Type | Description |
|---|---|---|
ctx | context.Context | Cancellation context for the access-controlled update transaction. |
id | string | The document to update. |
input | Draft | The generated draft patch. Nil fields retain saved values; core.Null clears an editorial field. Keyed rows preserve their occurrence identities. |
options | TypedMutationOptions | Caller identity, locale and ExpectedRevision from the last working read. Draft is forced to true. |
Returns
The saved working document with a new revision, or an operation error such as conflict for a stale ExpectedRevision.
(Document, error)How it works
Saved pending values remain separate from live content. Publish validates the complete working candidate before replacing the live snapshot; DiscardDraft resets the working head to that live snapshot.
Full signature
func (collection BoundTypedCollection[Document, Create, Update, Draft]) SaveDraft(
ctx context.Context,
id string,
input Draft,
options TypedMutationOptions,
) (Document, error)Related types
BoundTypedCollectionTyped collection methods for strict writes, incomplete working drafts, publication, reads, and deletion.
TypedMutationOptionsActor, draft intent, expected revision, locale, and response controls for a generated Go mutation.