array_delta
An array_delta is a type of delta that modifies an array.
This type of $collection should be used when array order is important.
One and only one of replace, insert, set, or remove must be specified.
The array is created if it does not yet exist.
The route.jobs field can only be modified using the replace, insert, or remove fields.
The schedule.jobs field can be modified by using the set field only.
| Name | Type | Description |
|---|---|---|
| $collection | string | Required. Must be "array" for an array_delta. |
| $path | string | Required on top-level deltas. The JSON path to modify. See Paths for a list of valid paths. |
| index | integer | Optional. The index where the insert operation is performed at. |
| insert | any[] | Optional. Insert values into the existing array at index. |
| remove | any[] | Optional. Remove existing values that match these selectors; for example, "job1" or { "id": "job1" }. |
| replace | any[] | Optional. Replace the existing array with a new array. |
| set | array_index_setter[] | Optional. Set specific indexes of the existing array. |
array_index_setter
| Name | Type | Description |
|---|---|---|
| index | integer | Required. The index where the set operation is performed at. If higher than the length of the array, the array is padded with nulls. |
| value | any | Required. The element at index is set to this value. |
route.jobs Unique Values
Any modification to route.jobs moves jobs.
That is, before the insert, remove or replace is performed,
the jobs are first removed from their current positions.
This ensures that jobs are never duplicated on multiple routes.
Examples
A revision using an array_delta to insert two jobs into a route:
{
"deltas": [{
$path: ["route", { id: "route0" }, "jobs"],
$collection: "array",
index: 3,
insert: [ "job3", "job5", "job7" ],
}]
}
A revision creating a job and using an array_index_setter to make it the 12th job (ordinal 11) in the schedule:
{
"deltas": [{
"$path": ["job"],
"$collection": "keyed_array",
"ids": ["job2"]
"assign": {
location: "marker1",
time_on_site: "00:10:00",
}
}, {
"$path": ["schedule", { id: "schedule0" }, "jobs"],
"set": [{
"index": 11,
"value": "job2"
}]
}]
}