RDoc-4008 Documents > Patching (Reorganization) + JsonPatch behavior - #2583
Conversation
531cc7a to
4a465d5
Compare
| @@ -324,7 +324,35 @@ | |||
| "key": "/client-api/operations/patching", | |||
| "value": { | |||
| "targetUrl": "/client-api/operations/patching/single-document", | |||
| "minimumVersion": "6.2" | |||
| "minimumVersion": "7.2" | |||
There was a problem hiding this comment.
This change (from 6.2 to 7.2) is a workaround to make the build pass until RDoc-4009 is fixed.
|
======================================= ====================================== ======================================= ========================================== =========================================== |
…=> /patch-multiple-documents/client-api
c257ed0 to
714ed01
Compare
| | **add(U item)** | `JavaScriptArray<U>` | Adds one item to the end of the array. | | ||
| | **add(U... items)** | `JavaScriptArray<U>` | Adds multiple items to the end of the array. | | ||
| | **add(Collection<U> items)** | `JavaScriptArray<U>` | Adds the items of the given collection to the end of the array. | | ||
| | **removeAt(int index)** | `JavaScriptArray<U>` | Removes the item in position `index` in the array. An out-of-range index is applied as a no-op. | |
There was a problem hiding this comment.
Maybe it worth mentioning negative index, something like:
A negative index will remove from the end of the array. removeAt(-N) removes the last N element
| @@ -0,0 +1,294 @@ | |||
| import Admonition from '@theme/Admonition'; | |||
There was a problem hiding this comment.
Can you add what happens on operation failure?
There was a problem hiding this comment.
done.
added info in this file and also in api-overview.mdx.
|
|
||
| Map<String, Object> values = new HashMap<>(); | ||
| values.put("name", "HeartRates"); | ||
| values.put("timestamp", NetISO8601Utils.format(new Date(), true)); |
There was a problem hiding this comment.
There is no need to use NetISO8601Utils.format function. Please fix in all relevant examples
| patchRequest.setScript("this['@metadata']['@expires'] = args.expires;"); | ||
| // @expires must contain an ISO 8601 UTC date-time string | ||
| patchRequest.setValues(Collections.singletonMap("expires", | ||
| NetISO8601Utils.format(DateUtils.addMinutes(new Date(), 1), true))); |
There was a problem hiding this comment.
Same here, the use of NetISO8601Utils.format is reduant
| Compare against `undefined` rather than calling `hasOwnProperty`, | ||
| which reports every property name as present on the patched document. |
There was a problem hiding this comment.
drop hasOwnProperty since it will throw either way.
|
|
||
| Parameters parameters = new Parameters(); | ||
| parameters.put("timeSeriesName", "PriceHistory"); | ||
| parameters.put("timestamp", NetISO8601Utils.format(new Date(), true)); |
| patchRequest.script = ` | ||
| if (this.SensitiveData != null) { | ||
| // Generate a fresh 96-bit IV for this encryption. | ||
| const iv = crypto.getRandomValuesBase64(12); | ||
|
|
||
| // The key comes from patchRequest.values; do not store it in the document. | ||
| this.SensitiveDataEncrypted = crypto.encryptAesGcm( | ||
| iv, | ||
| args.encryptionKey, | ||
| this.SensitiveData); | ||
|
|
||
| this.SensitiveDataIv = iv; | ||
|
|
||
| // Remove the plaintext only after encryption succeeds. | ||
| delete this.SensitiveData; | ||
| }`; | ||
|
|
||
| await documentStore.operations.send(new PatchOperation( | ||
| "users/1", | ||
| null, | ||
| patchRequest)); | ||
| ``` |
There was a problem hiding this comment.
This example is missing patchRequest.values, so args.encryptionKey in the script is never supplied and the patch will not work as shown.
| patchRequest.script = ` | |
| if (this.SensitiveData != null) { | |
| // Generate a fresh 96-bit IV for this encryption. | |
| const iv = crypto.getRandomValuesBase64(12); | |
| // The key comes from patchRequest.values; do not store it in the document. | |
| this.SensitiveDataEncrypted = crypto.encryptAesGcm( | |
| iv, | |
| args.encryptionKey, | |
| this.SensitiveData); | |
| this.SensitiveDataIv = iv; | |
| // Remove the plaintext only after encryption succeeds. | |
| delete this.SensitiveData; | |
| }`; | |
| await documentStore.operations.send(new PatchOperation( | |
| "users/1", | |
| null, | |
| patchRequest)); | |
| ``` | |
| patchRequest.script = ` | |
| if (this.SensitiveData != null) { | |
| // Generate a fresh 96-bit IV for this encryption. | |
| const iv = crypto.getRandomValuesBase64(12); | |
| // The key comes from patchRequest.values; do not store it in the document. | |
| this.SensitiveDataEncrypted = crypto.encryptAesGcm( | |
| iv, | |
| args.encryptionKey, | |
| this.SensitiveData); | |
| this.SensitiveDataIv = iv; | |
| // Remove the plaintext only after encryption succeeds. | |
| delete this.SensitiveData; | |
| }`; | |
| patchRequest.values = { | |
| encryptionKey | |
| }; | |
| await documentStore.operations.send(new PatchOperation( | |
| "users/1", | |
| null, | |
| patchRequest)); |
Issue links
https://issues.hibernatingrhinos.com/issue/RDoc-4008/Per-feature-reorganization-Patching
https://issues.hibernatingrhinos.com/issue/RDoc-3986/Document-JsonPatch-behavior-for-session-Patch-methods
https://issues.hibernatingrhinos.com/issue/RDoc-2719/Client-API-Operations-Patching-Single-document-Fix-article
https://issues.hibernatingrhinos.com/issue/RDoc-2721/Client-API-Operations-Patching-Set-based-Fix-article
https://issues.hibernatingrhinos.com/issue/RDoc-3908/Dictionary-patching-with-the-strongly-typed-Session-API
https://issues.hibernatingrhinos.com/issue/RDoc-4037/Patching-a-modified-document-tracked-by-the-same-session-other-fixes
Additional description
As described in:
https://issues.hibernatingrhinos.com/issue/RDoc-4008/Per-feature-reorganization-Patching
As described in:
https://issues.hibernatingrhinos.com/issue/RDoc-2719/Client-API-Operations-Patching-Single-document-Fix-article
As described in:
https://issues.hibernatingrhinos.com/issue/RDoc-2721/Client-API-Operations-Patching-Set-based-Fix-article
Type of change
/templatesor readme)Changes in docs URLs
/scripts/redirects.jsonfile, setDocuments MovedPR label)Changes in UX/UI