method

BoundTypedCollection.CreateDraft

Save an incomplete new document using its generated draft input model.

Example

go
pages := generated.PagesCollection.With(app.Local())
draft, err := pages.CreateDraft(
  ctx,
  generated.PageDraft{Title: core.Set("Working title")},
  core.TypedMutationOptions{
    Actor: &session.User,
    ActorCollection: session.Collection,
  },
)
if err != nil {
  return err
}
// The required layout can be completed before publishing.
_ = draft.ID

Arguments

ArgumentTypeDescription
ctxcontext.ContextCancellation context for the access-controlled create transaction.
inputDraftThe generated draft model. Nil fields are omitted; core.Null explicitly clears an editorial value. Supplied identities and field types remain validated.
optionsTypedMutationOptionsCaller identity and content locale. Draft is forced to true; use Create with Draft set to false for a complete published create.

Returns

The saved working document, or the operation error. The create does not produce a live snapshot.

(Document, error)

How it works

The generated handle uses the same Local API authorization, hooks and transaction as untyped creates. Editorial requiredness is deferred until publication, not field types, access, identities or structural validation.

Full signature

func (collection BoundTypedCollection[Document, Create, Update, Draft]) CreateDraft( ctx context.Context, input Draft, options TypedMutationOptions, ) (Document, error)

Source core/typed_local.go:63

Related types

  • BoundTypedCollection

    Typed collection methods for strict writes, incomplete working drafts, publication, reads, and deletion.

  • TypedMutationOptions

    Actor, draft intent, expected revision, locale, and response controls for a generated Go mutation.

Related guides