Skip to main content

populate

populate is a DML operation that sets multiple keys on an existing mapping.

Use it after define when you have several fields for the same object.

YOp

- populate:
path: config/database
values:
host: localhost
port: 5432

Parameters

ParameterTypeRequiredDescription
pathstringyesPath to the target mapping.
valuesmappingyesKey-value pairs to set on the mapping.

Behavior

  • Requires the target path to exist.
  • Requires the target to be a mapping.
  • Sets every key in values.
  • Overwrites existing keys with the same names.
  • Fails if a nested value key collides with a scalar or null intermediate.

Errors

ErrorMeaning
PATH_NOT_FOUNDTarget path does not exist.
NOT_A_MAPPINGTarget is not a mapping.
INVALID_PATHA value key cannot be written because an existing intermediate blocks traversal.

Example

yops:
- define:
path: config
- define:
path: config/database
- populate:
path: config/database
values:
host: localhost
port: 5432

Output:

config:
database:
host: localhost
port: 5432