set_delta
A set_delta
is a type of delta that
adds and removes strings from a string array that contains unique values and for which order does not matter.
A set_delta
can be used on the route.route_attributes or job.allowed_days_of_week fields, for example.
If both are specified, the remove
is performed before the add
.
Name | Type | Description |
---|---|---|
$collection | string | Required. Must be "set" for a set_delta . |
$default | string[] | Optional. Defaults to [] . If the delta is attempting to modify a non-existent array , create it first, using this value as the template. |
$path | string | Required on top-level deltas. The JSON path to modify. See Paths for a list of valid paths. |
add | string[] | Optional. Add strings to the existing array. |
remove | string[] | Optional. Remove strings from the existing array. |
Examples
Example of a revision using a set_delta
to modify route.route_attributes:
{
"deltas": [{
"$path": ["route"],
"$collection": "keyed_array",
"ids": ["route0", "route1"],
"assign": {
"route_attributes": {
"$collection": "set",
"add": ["refrigeration"],
"remove": ["licenced"],
},
},
}]
}
The $default
field can be used to make bulk edits to job.allowed_days_of_week work consistently, regardless of the existing field value.
Example of a revision using a set_delta
with a $default
value:
{
"deltas": [{
"$path": ["jobs"],
"$collection": "keyed_array",
"ids": ["job0", "job1", "job2"],
"assign_template": {
"allowed_days_of_week": {
"$collection": "set",
// use $default to ensure consistent behaviour if job.allowed_days_of_week is null or undefined
"$default": ["mon", "tue", "wed", "thu", "fri", "sat", "sun"],
"remove": ["mon"]
},
}
}]
}