Skip to main content

set

set is a DML operation that writes one value at a path.

Use it for upserts: it creates missing mapping ancestors and overwrites the final value if it already exists.

YOp

- set:
path: config/database/host
value: localhost

Parameters

ParameterTypeRequiredDescription
pathstringyesTarget path to write.
valueanyyesYAML value to write. Scalars, sequences, mappings, booleans, and null are valid.

Behavior

  • Creates missing intermediate mapping keys.
  • Overwrites an existing value at the final path.
  • Fails if an intermediate value is a scalar or null and cannot be traversed.
  • It is the only operation that lazily creates missing ancestors.

Errors

ErrorMeaning
INVALID_PATHThe path cannot be traversed, usually because an intermediate is not a mapping or sequence that supports the next segment.

Example

yops:
- set:
path: config/database/host
value: localhost

Input:

{}

Output:

config:
database:
host: localhost