Common Options
This section contains common option definitions for action handlers.

Assign To

Commonly used to assign action results to context fields.
Example 1: Direct assignment
Allow to assign value directly to
1
# assign value to context's `ctx` field `target`
2
# <assignTo> is action specific name and may generally can be either simply `assignTo` or more descrete `assignSomethingTo`
3
'<assignTo>': $.ctx.target
Copied!
Short name syntax accepts a path to context field.
When path assignment targets context following rules are applied: Value assignment is only possible to ctx, secrets or parameters.
Example 2: Multi assignment
Then example above can also be written in the following way:
1
'<assignTo>':
2
ctx: $.target
Copied!
The main advantage of this alternative syntax is the ability to assign to multiple values and override the entire target object.
Let's say we want to save value into both ctx and parameters, we can leverage that with:
1
'<assignTo>':
2
ctx: $.target
3
parameters: $.paramsTarget
Copied!
Another example is with field override functionality.
Let assume we currently have the following context state:
1
ctx:
2
something:
3
a: 1
4
b: 2
Copied!
and we want to assign to ctx.something entirell new object:
1
'<assignTo>':
2
ctx: '$.something'
3
# if override is not provided assigned value and existing will be merged
4
override: true
Copied!

Push To

Another common usecase is to push some value into array.
1
# push some value to `ctx.something` field array
2
# if field is missing - it will be created with array and one pushed element in it
3
'<pushTo>': '$.ctx.something'
Copied!
Similar to assignTo functionality pushTo can push values into multiple targets, override original value.
But additionally to that there is one more option that works only when pushed value is array - pushing its items to the target array instead of the array itself:
1
'<pushTo>':
2
ctx: '$.target'
3
# if children option is passed value's array items will be pushed to `target` array instead of pushing value itself
4
children: true
Copied!
Last modified 3yr ago
Copy link