Patch per document
It is a common use-case for end users to want to patch a list of documents with certain metadata attributes.
user makes a PATCH request:
{
"query": {
"ids": [
"record1",
"record2",
.
.
.
]
},
"ops": [
{
"op": "add",
"path": "/acl/viewers/-",
"value": "acl1"
},
{
"op": "add",
"path": "/acl/viewers/-",
"value": "acl2"
}
]
}
The expectation is that all records should have acl1 and acl2 as part of viewers acl. If acl1 or acl2 is already present for any records, it should be a no-op
Consider following scenario: record1 has acl/viewers: ["acl1"] record2 has acl/viewers: ["acl2]
This operation (or list of operations), if applied as-is, will create duplicate acl/viewers for certain records. To avoid this, record1 should only apply the second patch and record2 should only apply the first patch. Therefore, we can have a map input where cosmos patch operation can be different for each document. Corresponding mapping for Partition keys is also maintained
This is what the client (i.e. storage) is expected to generate when calling the bulk patch method.