method

LocalAPI.Duplicate

func (local *LocalAPI) Duplicate( ctx context.Context, collection, id string, overrides store.Values, actor *store.Document, localeOptions ...LocaleOptions, ) (store.Document, error)

Create a document from an access-checked source and apply overrides.

Source core/local.go:262

@param ctx
Request context.
@param collection
Authored collection slug.
@param id
Source document ID.
@param overrides
Values applied to the copy before create validation.
@param actor
Authenticated actor, or nil.
@param localeOptions
Optional locale selection.
@returns
The authorized copy, or an operation error.

The source must pass read access. The copy then runs create access, duplicate hooks, validation, persistence, and version logic.

Example

go
copy, err := app.Local().Duplicate(ctx, "posts", sourceID, store.Values{
  "title": store.String("Copy of the original"),
}, actor)

Related types

  • LocalAPI

    In-process content operations that share the REST authorization and lifecycle pipeline.

  • Values

    A map of field names to typed values.

  • Document

    A stored document with status and version metadata.

  • LocaleOptions

    Locale selection for one single-document Local API operation.