Edit an entire document, relying on Typegen for the type.
Document options including documentId
, documentType
, and optionally projectId
/dataset
.
A stable function to update the document state. Accepts either the new document state or an updater function (currentValue) => nextValue
.
Returns a promise resolving to the ActionsResult.
Edit a specific path within a document, relying on Typegen for the type.
Document options including documentId
, documentType
, path
, and optionally projectId
/dataset
.
A stable function to update the value at the specified path. Accepts either the new value or an updater function (currentValue) => nextValue
.
Returns a promise resolving to the ActionsResult.
Edit an entire document with an explicit type TData
.
Document options including documentId
and optionally projectId
/dataset
.
A stable function to update the document state. Accepts either the new document state (TData
) or an updater function (currentValue: TData) => nextValue: TData
.
Returns a promise resolving to the ActionsResult.
Edit a specific path within a document with an explicit type TData
.
Document options including documentId
, path
, and optionally projectId
/dataset
.
A stable function to update the value at the specified path. Accepts either the new value (TData
) or an updater function (currentValue: TData) => nextValue: TData
.
Returns a promise resolving to the ActionsResult.
Provides a stable function to apply edits to a document or a specific path within it.
Remarks
This hook simplifies editing documents by automatically:
set
andunset
operations required for the update viaeditDocument
.edit(prev => ({...prev, title: 'New'}))
).useApplyDocumentActions
internally for optimistic updates and transaction handling.It offers several overloads for flexibility:
This hook relies on the document state being loaded. If the document is not yet available (e.g., during initial load), the component using this hook will suspend.
Example: Basic Usage (Typegen, Full Document)
Example: Editing a Specific Path (Typegen)
Example: Usage with Explicit Types (Full Document)
Example: Usage with Explicit Types (Specific Path)