function

ReplaceChild

ReplaceChild deliberately replaces one direct child, including its kind, policies, and attachments. Unrelated children and the parent's own policies are preserved. A failed replacement returns the original parent and an error.

Arguments

ArgumentTypeDescription
parentParentThe parent value.
namestringThe name value.
replacementNodeThe replacement value.

Returns

The declared result.

(Parent, error)

Full signature

func ReplaceChild[Parent interface { Node EditChildren(func(*ChildrenDraft) error) (Parent, error) }](parent Parent, name string, replacement Node) (Parent, error)

Source field/child_edit.go:37

Related types

  • Node

    Node is any field definition that can be placed in Fields. Authors normally create nodes with constructors such as Text, Select, Group, or Array and use their concrete fluent methods before adding them to a field list. The interface is sealed so Ridu can snapshot every supported field safely.

  • ChildrenDraft

    ChildrenDraft owns a detached slice. Committing snapshots again, so retained drafts cannot mutate published graphs. Structural edits are explicit.