Skip to content

RDoc-4008 Documents > Patching (Reorganization) + JsonPatch behavior - #2583

Merged
ppekrol merged 10 commits into
ravendb:mainfrom
Danielle9897:RDoc-3986-jsonPatchBehavior
Aug 11, 2026
Merged

RDoc-4008 Documents > Patching (Reorganization) + JsonPatch behavior#2583
ppekrol merged 10 commits into
ravendb:mainfrom
Danielle9897:RDoc-3986-jsonPatchBehavior

Conversation

@Danielle9897

@Danielle9897 Danielle9897 commented Jul 28, 2026

Copy link
Copy Markdown
Member

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

Type of change

  • Content - docs
  • Content - cloud
  • Content - guides
  • Content - start pages/other
  • New docs feature (consider updating /templates or readme)
  • Bug fix
  • Optimization
  • Other

Changes in docs URLs

  • No changes in docs URLs
  • [s] Articles are restructured, URLs will change, mapping is required (update /scripts/redirects.json file, set Documents Moved PR label)

Changes in UX/UI

  • No changes in UX/UI
  • Changes in UX/UI (include screenshots and description)

@Danielle9897
Danielle9897 force-pushed the RDoc-3986-jsonPatchBehavior branch 2 times, most recently from 531cc7a to 4a465d5 Compare July 28, 2026 16:17
Comment thread scripts/redirects.json
@@ -324,7 +324,35 @@
"key": "/client-api/operations/patching",
"value": {
"targetUrl": "/client-api/operations/patching/single-document",
"minimumVersion": "6.2"
"minimumVersion": "7.2"

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This change (from 6.2 to 7.2) is a workaround to make the build pass until RDoc-4009 is fixed.

@Danielle9897

Danielle9897 commented Jul 28, 2026

Copy link
Copy Markdown
Member Author

=======================================
C#:
@ppekrol / @Lwiel pls review these files:

..\documents\patching-documents\overview.mdx
..\documents\patching-documents\patch-a-single-document\content\_api-overview-csharp.mdx
..\documents\patching-documents\patch-a-single-document\content\_json-patch-csharp.mdx
..\documents\patching-documents\patch-a-single-document\examples\content\_patch-examples-advanced-scripts-csharp.mdx
..\documents\patching-documents\patch-a-single-document\examples\content\_patch-examples-counters-time-series-attachments-csharp.mdx
..\documents\patching-documents\patch-a-single-document\examples\content\_patch-examples-documents-and-metadata-csharp.mdx
..\documents\patching-documents\patch-a-single-document\examples\content\_patch-examples-fields-and-arrays-csharp.mdx
..\documents\patching-documents\patch-multiple-documents\content\_client-api-csharp.mdx
..\documents\patching-documents\patch-multiple-documents\patch-view.mdx
..\docs\client-api\configuration\content\_conventions-csharp.mdx

======================================
Python:
@poissoncorp pls review these files:

..\documents\patching-documents\patch-a-single-document\content\_api-overview-python.mdx
..\documents\patching-documents\patch-a-single-document\examples\content\_patch-examples-advanced-scripts-python.mdx
..\documents\patching-documents\patch-a-single-document\examples\content\_patch-examples-counters-time-series-attachments-python.mdx
..\documents\patching-documents\patch-a-single-document\examples\content\_patch-examples-documents-and-metadata-python.mdx
..\documents\patching-documents\patch-a-single-document\examples\content\_patch-examples-fields-and-arrays-python.mdx
..\documents\patching-documents\patch-multiple-documents\content\_client-api-python.mdx

=======================================
Node.js:
@M4xymm pls review these files:

..\documents\patching-documents\patch-a-single-document\content\_api-overview-nodejs.mdx
..\documents\patching-documents\patch-a-single-document\examples\content\_patch-examples-advanced-scripts-nodejs.mdx
..\documents\patching-documents\patch-a-single-document\examples\content\_patch-examples-counters-time-series-attachments-nodejs.mdx
..\documents\patching-documents\patch-a-single-document\examples\content\_patch-examples-documents-and-metadata-nodejs.mdx
..\documents\patching-documents\patch-a-single-document\examples\content\_patch-examples-fields-and-arrays-nodejs.mdx
..\documents\patching-documents\patch-multiple-documents\content\_client-api-nodejs.mdx

==========================================
Java:
@LielNagar pls review these files:

..\documents\patching-documents\patch-a-single-document\content\_api-overview-java.mdx
..\documents\patching-documents\patch-a-single-document\examples\content\_patch-examples-advanced-scripts-java.mdx
..\documents\patching-documents\patch-a-single-document\examples\content\_patch-examples-counters-time-series-attachments-java.mdx
..\documents\patching-documents\patch-a-single-document\examples\content\_patch-examples-documents-and-metadata-java.mdx
..\documents\patching-documents\patch-a-single-document\examples\content\_patch-examples-fields-and-arrays-java.mdx
..\documents\patching-documents\patch-multiple-documents\content\_client-api-java.mdx

===========================================

@Danielle9897
Danielle9897 marked this pull request as draft August 3, 2026 08:43
@Danielle9897
Danielle9897 requested a review from Lwiel August 3, 2026 12:00
@Danielle9897
Danielle9897 force-pushed the RDoc-3986-jsonPatchBehavior branch from c257ed0 to 714ed01 Compare August 3, 2026 13:05
@Danielle9897
Danielle9897 marked this pull request as ready for review August 3, 2026 13:09
| **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&lt;U&gt; 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. |

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

@@ -0,0 +1,294 @@
import Admonition from '@theme/Admonition';

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you add what happens on operation failure?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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));

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is no need to use NetISO8601Utils.format function. Please fix in all relevant examples

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

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)));

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same here, the use of NetISO8601Utils.format is reduant

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

Comment on lines +1376 to +1377
Compare against `undefined` rather than calling `hasOwnProperty`,
which reports every property name as present on the patched document.

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

drop hasOwnProperty since it will throw either way.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done


Parameters parameters = new Parameters();
parameters.put("timeSeriesName", "PriceHistory");
parameters.put("timestamp", NetISO8601Utils.format(new Date(), true));

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same reduant use of NetISO8601Utils

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

@Danielle9897
Danielle9897 requested a review from LielNagar August 4, 2026 04:47
Comment on lines +275 to +296
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));
```

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This example is missing patchRequest.values, so args.encryptionKey in the script is never supplied and the patch will not work as shown.

Suggested change
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));

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

@Danielle9897
Danielle9897 requested a review from M4xymm August 4, 2026 14:27
@Danielle9897
Danielle9897 marked this pull request as draft August 5, 2026 06:31
@Danielle9897
Danielle9897 marked this pull request as ready for review August 5, 2026 11:44
@ppekrol
ppekrol merged commit 05951aa into ravendb:main Aug 11, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants