Skip to main content

define

define is a DDL operation that creates an empty mapping at a path.

Use it when you need a strict container creation step. It behaves like mkdir for one mapping key: the parent must already exist and the final key must be absent.

YOp

- define:
path: config/database

Parameters

ParameterTypeRequiredDescription
pathstringyesPath to create. The parent must exist and be a mapping. The final segment is created as {}.

Behavior

  • Creates the final path segment as an empty mapping.
  • Does not create missing ancestors.
  • Rejects index and match path segments such as items/[0].
  • Stops the operation list if the parent is missing, the parent is not a mapping, or the target key already exists.

Errors

ErrorMeaning
PATH_NOT_FOUNDParent path does not exist.
ALREADY_EXISTSThe target key already exists.
NOT_A_MAPPINGThe parent is not a mapping.
INVALID_PATHThe path uses a non-key segment.

Example

yops:
- define:
path: config
- define:
path: config/database

Input:

{}

Output:

config:
database: {}