Skip to content

Commit 1021196

Browse files
authored
(DOCSP-39536): Consolidate Write Data to a Synced Database page (#3286)
## Pull Request Info - SDK Docs Consolidation Jira ticket: https://jira.mongodb.org/browse/DOCSP-39536 *Staged Page* - [Write to a Synced Database](https://preview-mongodbdacharyc.gatsbyjs.io/realm/DOCSP-39536/sdk/sync/write-to-synced-database/) *Page Source* Add links to every SDK's pages where you got the SDK-specific information: - [C++: Write to a Synced Realm](https://www.mongodb.com/docs/atlas/device-sdks/sdk/cpp/sync/write-to-synced-realm/) - [Flutter: Write Data to a Synced Realm](https://www.mongodb.com/docs/atlas/device-sdks/sdk/flutter/sync/write-to-synced-realm/) - [Kotlin: Write to a Synced Realm](https://www.mongodb.com/docs/atlas/device-sdks/sdk/kotlin/sync/write-to-synced-realm/) - [.NET: Write to a Synced Realm](https://www.mongodb.com/docs/atlas/device-sdks/sdk/dotnet/sync/write-to-synced-realm/) - [Swift: Write Data to a Synced Realm](https://www.mongodb.com/docs/atlas/device-sdks/sdk/swift/sync/write-to-synced-realm/) ### PR Author Checklist Before requesting a review for your PR, please check these items: - [x] Open the PR against the `feature-consolidated-sdk-docs` branch instead of `master` - [x] Tag the consolidated page for: - genre - meta.keywords - meta.description #### Naming - [x] Update Realm naming and the language around persistence layer/local/device per [this document](https://docs.google.com/document/d/126OczVxBWAwZ4P5ZsSM29WI3REvONEr1ald-mAwPtyQ/edit?usp=sharing) - [x] Include `.rst` files comply with [the naming guidelines](https://docs.google.com/document/d/1h8cr66zoEVeXytVfvDxlCSsUS5IZwvUQvfSCEXNMpek/edit#heading=h.ulh8b5f2hu9) #### Links and Refs - [x] Create new consolidated SDK ref targets starting with "_sdks-" for relevant sections - [x] Remove or update any SDK-specific refs to use the new consolidated SDK ref targets - [x] [Update any Kotlin API links](https://jira.mongodb.org/browse/DOCSP-32519) to use the new Kotlin SDK roles #### Content - [x] Shared code boxes have snippets or placeholders for all 9 languages - [x] API description sections have API details or a generic placeholder for all 9 languages - [x] Check related pages for relevant content to include - [x] Create a ticket for missing examples in each relevant SDK: Consolidation Gaps epic ### Reviewer Checklist As a reviewer, please check these items: - [x] Shared code example boxes contain language-specific snippets or placeholders for every language - [x] API reference details contain working API reference links or generic content - [ ] Realm naming/language has been updated - [x] All relevant content from individual SDK pages is present on the consolidated page
1 parent c607575 commit 1021196

15 files changed

+852
-2
lines changed
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
The :cpp-sdk:`compensating_writes_info()
2+
<structrealm_1_1internal_1_1bridge_1_1sync__error.html>`
3+
function provides an array of ``compensating_write_error_info``
4+
structs that contain:
5+
6+
- The ``object_name`` of the object the client attempted to write
7+
- The ``primary_key`` of the specific object
8+
- The ``reason`` for the compensating write error
9+
10+
This information is the same information you can find in the
11+
:ref:`App Services logs <logs-sync>`. The C++ SDK exposes this object on the
12+
client for convenience and debugging purposes.
13+
14+
The following shows an example of how you might log information
15+
about compensating write errors:
16+
17+
.. io-code-block::
18+
19+
.. input:: /examples/generated/cpp/sync-errors.snippet.get-compensating-write-error-info.cpp
20+
:language: cpp
21+
22+
.. output::
23+
:language: console
24+
25+
A write was rejected with a compensating write error.
26+
An object of type Item
27+
was rejected because write to ObjectID("6557ddb0bf050934870ca0f5") in
28+
table "Item" not allowed; object is outside of the current query view.
29+
30+
- The ``Item`` in this message is ``Item`` object used in the object model.
31+
- The ``table "Item"`` refers to the Atlas collection where this object would
32+
sync.
33+
- The reason ``object is outside of the current query view`` in this message
34+
is because the query subscription was set to require the object's ``complexity``
35+
property to be less than or equal to ``4``. The client attempted to write an
36+
object outside of this boundary.
37+
- The primary key is the ``objectId`` of the specific object the client
38+
attempted to write.
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
The .NET SDK exposes a ``CompensatingWrites`` field on a
2+
:dotnet-sdk:`CompensatingWriteException <reference/Realms.Sync.Exceptions.CompensatingWriteException.html>`.
3+
You can access this information through the :ref:`Sync error handler
4+
<sdks-handle-sync-errors>`.
5+
6+
When a ``CompensatingWriteException`` is thrown, it includes an enumerable of
7+
:dotnet-sdk:`CompensatingWriteInfo <reference/Realms.Sync.Exceptions.CompensatingWriteInfo.html>`
8+
objects. Each ``CompensatingWriteInfo`` object contains properties that describe
9+
the object type, its primary key, and reason the server performed the compensating
10+
write.
11+
12+
This information is the same information you can find in the App Services logs.
13+
It is exposed on the client for convenience and debugging purposes.
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
The Flutter SDK exposes a ``compensatingWrites`` field on a
2+
:flutter-sdk:`CompensatingWriteError <realm/CompensatingWriteError-class.html>`.
3+
You can access this information through the :ref:`Sync error handler
4+
<sdks-handle-sync-errors>`.
5+
6+
This field contains an array of :flutter-sdk:`CompensatingWriteInfo
7+
<realm/CompensatingWriteInfo-class.html>` objects, which provide:
8+
9+
- The ``objectType`` of the object the client attempted to write
10+
- The ``primaryKey`` of the specific object
11+
- The ``reason`` for the compensating write error
12+
13+
This information is the same information you can find in the App Services logs.
14+
It is exposed on the client for convenience and debugging purposes.
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
The Node.js SDK exposes a ``writes`` field on a
2+
:js-sdk:`CompensatingWriteError <classes/Realm.CompensatingWriteError.html>`.
3+
You can access this information through the :ref:`Sync error handler
4+
<sdks-handle-sync-errors>`.
5+
6+
This field contains an array of :js-sdk:`CompensatingWriteInfo
7+
<types/Realm.CompensatingWriteInfo.html>` objects, which provide:
8+
9+
- The ``objectName`` of the object the client attempted to write
10+
- The ``primaryKey`` of the specific object
11+
- The ``reason`` for the compensating write error
12+
13+
This information is the same information you can find in the App Services logs.
14+
It is exposed on the client for convenience and debugging purposes.
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
The :kotlin-sync-sdk:`CompensatingWriteInfo
2+
<io.realm.kotlin.mongodb.exceptions/-compensating-write-exception/-compensating-write-info/index.html>`
3+
object provides:
4+
5+
- The ``objectType`` of the object the client attempted to write
6+
- The ``primaryKey`` of the specific object
7+
- The ``reason`` for the compensating write error
8+
9+
This information is the same information you can find in the :ref:`App Services
10+
logs <logs-sync>`. The Kotlin SDK exposes this object on the client for
11+
convenience and debugging purposes.
12+
13+
The following shows an example of how you might log information
14+
about compensating write errors:
15+
16+
.. io-code-block::
17+
18+
.. input:: /examples/generated/kotlin/SyncedRealmCRUD.snippet.access-compensating-write.kt
19+
:language: kotlin
20+
21+
.. output::
22+
:language: console
23+
24+
A write was rejected with a compensating write error
25+
The write to object type: Item
26+
With primary key of: RealmAny{type=OBJECT_ID, value=BsonObjectId(649f2c38835cc0346b861b74)}
27+
Was rejected because: write to "649f2c38835cc0346b861b74" in table "Item" not allowed; object is outside of the current query view
28+
29+
- The ``Item`` in this message is ``Item`` object used in the object model on
30+
this page.
31+
- The primary key is the ``objectId`` of the specific object the client
32+
attempted to write.
33+
- The ``table "Item"`` refers to the Atlas collection where this object would
34+
sync.
35+
- The reason ``object is outside of the current query view`` in this example is
36+
because the query subscription was set to require the object's ``complexity``
37+
property to be less than or equal to ``4``, and the client attempted to
38+
write an object outside of this boundary.
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
The Swift SDK exposes a :swift-sdk:`compensatingWriteInfo
2+
<Typealiases.html#/s:10RealmSwift21CompensatingWriteInfoa>` field on a
3+
SyncError whose code is ``.writeRejected``. You can access this information
4+
through the :ref:`Sync error handler <sdks-handle-sync-errors>`.
5+
6+
This field contains an array of :objc-sdk:`RLMCompensatingWriteInfo
7+
<Classes/RLMCompensatingWriteInfo.html>` objects, which provide:
8+
9+
- The ``objectType`` of the object the client attempted to write
10+
- The ``primaryKey`` of the specific object
11+
- The ``reason`` for the compensating write error
12+
13+
This information is the same information you can find in the App Services logs.
14+
It is exposed on the client for convenience and debugging purposes.
15+
16+
.. example::
17+
18+
This error handler shows an example of how you might log information
19+
about compensating write errors:
20+
21+
.. literalinclude:: /examples/generated/code/start/Errors.snippet.access-compensating-write.swift
22+
:language: swift
23+
24+
The example error handler above produces this output when a compensating
25+
write error occurs:
26+
27+
.. code-block:: console
28+
29+
A write was rejected with a compensating write error
30+
The write to object type: Optional("Item")
31+
With primary key of: objectId(641382026852d9220b2e2bbf)
32+
Was rejected because: Optional("write to \"641382026852d9220b2e2bbf\" in table \"Item\" not
33+
allowed; object is outside of the current query view")
34+
35+
- The ``Optional("Item")`` in this message is an ``Item`` object used in the
36+
:github:`Swift Template App <mongodb/template-app-swiftui-todo>`.
37+
- The primary key is the ``objectId`` of the specific object the client
38+
attempted to write.
39+
- The ``table \"Item"\`` refers to the Atlas collection where this object
40+
would sync.
41+
- The reason ``object is outside of the current query view`` in this example
42+
is because the query subscription was set to require the object's ``isComplete``
43+
property to be ``true``, and the client attempted to write an object where
44+
this property was ``false``.
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
The Node.js SDK exposes a ``writes`` field on a
2+
:js-sdk:`CompensatingWriteError <classes/Realm.CompensatingWriteError.html>`.
3+
You can access this information through the :ref:`Sync error handler
4+
<sdks-handle-sync-errors>`.
5+
6+
This field contains an array of :js-sdk:`CompensatingWriteInfo
7+
<types/Realm.CompensatingWriteInfo.html>` objects, which provide:
8+
9+
- The ``objectName`` of the object the client attempted to write
10+
- The ``primaryKey`` of the specific object
11+
- The ``reason`` for the compensating write error
12+
13+
This information is the same information you can find in the App Services logs.
14+
It is exposed on the client for convenience and debugging purposes.
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
.. tabs-drivers::
2+
3+
tabs:
4+
- id: cpp-sdk
5+
content: |
6+
7+
.. literalinclude:: /examples/generated/cpp/sync-errors.snippet.compensating-write-model.cpp
8+
:language: cpp
9+
10+
- id: csharp
11+
content: |
12+
13+
.. literalinclude:: /examples/MissingPlaceholders/example.cs
14+
:language: csharp
15+
16+
- id: dart
17+
content: |
18+
19+
.. literalinclude:: /examples/generated/flutter/write_to_synced_realm_test.snippet.realm-model.dart
20+
:language: dart
21+
22+
- id: javascript
23+
content: |
24+
25+
.. literalinclude:: /examples/MissingPlaceholders/example.js
26+
:language: javascript
27+
28+
- id: kotlin
29+
content: |
30+
31+
.. literalinclude:: /examples/generated/kotlin/SyncedRealmCRUD.snippet.flexible-sync-crud-model.kt
32+
:language: kotlin
33+
34+
- id: swift
35+
content: |
36+
37+
.. literalinclude:: /examples/generated/code/start/SyncedRealmCRUD.snippet.flexible-sync-crud-model.swift
38+
:language: swift
39+
40+
- id: typescript
41+
content: |
42+
43+
.. literalinclude:: /examples/MissingPlaceholders/example.ts
44+
:language: typescript
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
.. tabs-drivers::
2+
3+
tabs:
4+
- id: cpp-sdk
5+
content: |
6+
7+
.. literalinclude:: /examples/generated/cpp/sync-errors.snippet.compensating-write-setup.cpp
8+
:language: cpp
9+
10+
- id: csharp
11+
content: |
12+
13+
.. literalinclude:: /examples/generated/dotnet/FlexibleSyncExamples.snippet.example_sub.cs
14+
:language: csharp
15+
:copyable: false
16+
17+
- id: dart
18+
content: |
19+
20+
.. literalinclude:: /examples/generated/flutter/write_to_synced_realm_test.snippet.subscription-setup.dart
21+
:language: dart
22+
23+
- id: javascript
24+
content: |
25+
26+
.. literalinclude:: /examples/MissingPlaceholders/example.js
27+
:language: javascript
28+
29+
- id: kotlin
30+
content: |
31+
32+
.. literalinclude:: /examples/generated/kotlin/SyncedRealmCRUD.snippet.flexible-sync-subscription-setup.kt
33+
:language: kotlin
34+
35+
- id: swift
36+
content: |
37+
38+
.. literalinclude:: /examples/generated/code/start/SyncedRealmCRUD.snippet.flexible-sync-subscription-setup.swift
39+
:language: swift
40+
41+
- id: typescript
42+
content: |
43+
44+
.. literalinclude:: /examples/MissingPlaceholders/example.ts
45+
:language: typescript
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
.. tabs-drivers::
2+
3+
tabs:
4+
- id: cpp-sdk
5+
content: |
6+
7+
.. literalinclude:: /examples/generated/cpp/sync-errors.snippet.successful-write-example.cpp
8+
:language: cpp
9+
10+
- id: csharp
11+
content: |
12+
13+
.. literalinclude:: /examples/MissingPlaceholders/example.cs
14+
:language: csharp
15+
16+
- id: dart
17+
content: |
18+
19+
.. literalinclude:: /examples/generated/flutter/write_to_synced_realm_test.snippet.write-synced-realm.dart
20+
:language: dart
21+
22+
- id: javascript
23+
content: |
24+
25+
.. literalinclude:: /examples/MissingPlaceholders/example.js
26+
:language: javascript
27+
28+
- id: kotlin
29+
content: |
30+
31+
.. literalinclude:: /examples/generated/kotlin/SyncedRealmCRUD.snippet.successful-write.kt
32+
:language: kotlin
33+
34+
- id: swift
35+
content: |
36+
37+
.. literalinclude:: /examples/generated/code/start/SyncedRealmCRUD.snippet.successful-write.swift
38+
:language: swift
39+
40+
- id: typescript
41+
content: |
42+
43+
.. literalinclude:: /examples/MissingPlaceholders/example.ts
44+
:language: typescript

0 commit comments

Comments
 (0)