'set' – an overwriting operation: sets the full field value for primitive targets, and merges the provided value with existing values for objects
'append':
– array fields: appends new items to the end of the array,
string fields: '"existing content" "new content"'
text fields: '"existing content"\n"new content"'
number fields: existing + new
other field types not mentioned will set instead (dates, url)
'mixed' – sets non-array fields, and appends to array fields
'unset' – removes whatever value is on the target path
All operations except unset requires a value.
Appending in the middle of arrays
To append to an array, use the 'append' operation, and provide an array value with one or more array items.
target: {path: ['array'], operation: 'append', value: [{_type: 'item' _key: 'a'}]} will append the items in the value to the existing array.
To insert in the middle of the array, use target: {path: ['array', {_key: 'appendAfterKey'}], operation: 'append', value: [{_type: 'item' _key: 'a'}]}.
Here, {_type: 'item' _key: 'a'} will be appended after the array item with key 'appendAfterKey'
It is optional to provide a _key for inserted array items; if one isn't provided, it will be generated.
Determines how the target path will be patched.
Operation types
'set'
– an overwriting operation: sets the full field value for primitive targets, and merges the provided value with existing values for objects'append'
: – array fields: appends new items to the end of the array,'mixed'
– sets non-array fields, and appends to array fields'unset'
– removes whatever value is on the target pathAll operations except unset requires a
value
.Appending in the middle of arrays
To append to an array, use the 'append' operation, and provide an array value with one or more array items.
target: {path: ['array'], operation: 'append', value: [{_type: 'item' _key: 'a'}]}
will append the items in the value to the existing array.To insert in the middle of the array, use
target: {path: ['array', {_key: 'appendAfterKey'}], operation: 'append', value: [{_type: 'item' _key: 'a'}]}
. Here,{_type: 'item' _key: 'a'}
will be appended after the array item with key'appendAfterKey'
It is optional to provide a _key for inserted array items; if one isn't provided, it will be generated.