Skip to content

Commit

Permalink
Merge branch 'feature-consolidated-sdk-docs' into DOCSP-39535
Browse files Browse the repository at this point in the history
  • Loading branch information
dacharyc authored Jul 11, 2024
2 parents 3dc1603 + 1021196 commit da08965
Show file tree
Hide file tree
Showing 15 changed files with 854 additions and 2 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
The :cpp-sdk:`compensating_writes_info()
<structrealm_1_1internal_1_1bridge_1_1sync__error.html>`
function provides an array of ``compensating_write_error_info``
structs that contain:

- The ``object_name`` of the object the client attempted to write
- The ``primary_key`` of the specific object
- The ``reason`` for the compensating write error

This information is the same information you can find in the
:ref:`App Services logs <logs-sync>`. The C++ SDK exposes this object on the
client for convenience and debugging purposes.

The following shows an example of how you might log information
about compensating write errors:

.. io-code-block::

.. input:: /examples/generated/cpp/sync-errors.snippet.get-compensating-write-error-info.cpp
:language: cpp

.. output::
:language: console

A write was rejected with a compensating write error.
An object of type Item
was rejected because write to ObjectID("6557ddb0bf050934870ca0f5") in
table "Item" not allowed; object is outside of the current query view.

- The ``Item`` in this message is ``Item`` object used in the object model.
- The ``table "Item"`` refers to the Atlas collection where this object would
sync.
- The reason ``object is outside of the current query view`` in this message
is because the query subscription was set to require the object's ``complexity``
property to be less than or equal to ``4``. The client attempted to write an
object outside of this boundary.
- The primary key is the ``objectId`` of the specific object the client
attempted to write.
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
The .NET SDK exposes a ``CompensatingWrites`` field on a
:dotnet-sdk:`CompensatingWriteException <reference/Realms.Sync.Exceptions.CompensatingWriteException.html>`.
You can access this information through the :ref:`Sync error handler
<sdks-handle-sync-errors>`.

When a ``CompensatingWriteException`` is thrown, it includes an enumerable of
:dotnet-sdk:`CompensatingWriteInfo <reference/Realms.Sync.Exceptions.CompensatingWriteInfo.html>`
objects. Each ``CompensatingWriteInfo`` object contains properties that describe
the object type, its primary key, and reason the server performed the compensating
write.

This information is the same information you can find in the App Services logs.
It is exposed on the client for convenience and debugging purposes.
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
The Flutter SDK exposes a ``compensatingWrites`` field on a
:flutter-sdk:`CompensatingWriteError <realm/CompensatingWriteError-class.html>`.
You can access this information through the :ref:`Sync error handler
<sdks-handle-sync-errors>`.

This field contains an array of :flutter-sdk:`CompensatingWriteInfo
<realm/CompensatingWriteInfo-class.html>` objects, which provide:

- The ``objectType`` of the object the client attempted to write
- The ``primaryKey`` of the specific object
- The ``reason`` for the compensating write error

This information is the same information you can find in the App Services logs.
It is exposed on the client for convenience and debugging purposes.
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
The Node.js SDK exposes a ``writes`` field on a
:js-sdk:`CompensatingWriteError <classes/Realm.CompensatingWriteError.html>`.
You can access this information through the :ref:`Sync error handler
<sdks-handle-sync-errors>`.

This field contains an array of :js-sdk:`CompensatingWriteInfo
<types/Realm.CompensatingWriteInfo.html>` objects, which provide:

- The ``objectName`` of the object the client attempted to write
- The ``primaryKey`` of the specific object
- The ``reason`` for the compensating write error

This information is the same information you can find in the App Services logs.
It is exposed on the client for convenience and debugging purposes.
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
The :kotlin-sync-sdk:`CompensatingWriteInfo
<io.realm.kotlin.mongodb.exceptions/-compensating-write-exception/-compensating-write-info/index.html>`
object provides:

- The ``objectType`` of the object the client attempted to write
- The ``primaryKey`` of the specific object
- The ``reason`` for the compensating write error

This information is the same information you can find in the :ref:`App Services
logs <logs-sync>`. The Kotlin SDK exposes this object on the client for
convenience and debugging purposes.

The following shows an example of how you might log information
about compensating write errors:

.. io-code-block::

.. input:: /examples/generated/kotlin/SyncedRealmCRUD.snippet.access-compensating-write.kt
:language: kotlin

.. output::
:language: console

A write was rejected with a compensating write error
The write to object type: Item
With primary key of: RealmAny{type=OBJECT_ID, value=BsonObjectId(649f2c38835cc0346b861b74)}
Was rejected because: write to "649f2c38835cc0346b861b74" in table "Item" not allowed; object is outside of the current query view

- The ``Item`` in this message is ``Item`` object used in the object model on
this page.
- The primary key is the ``objectId`` of the specific object the client
attempted to write.
- The ``table "Item"`` refers to the Atlas collection where this object would
sync.
- The reason ``object is outside of the current query view`` in this example is
because the query subscription was set to require the object's ``complexity``
property to be less than or equal to ``4``, and the client attempted to
write an object outside of this boundary.
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
The Swift SDK exposes a :swift-sdk:`compensatingWriteInfo
<Typealiases.html#/s:10RealmSwift21CompensatingWriteInfoa>` field on a
SyncError whose code is ``.writeRejected``. You can access this information
through the :ref:`Sync error handler <sdks-handle-sync-errors>`.

This field contains an array of :objc-sdk:`RLMCompensatingWriteInfo
<Classes/RLMCompensatingWriteInfo.html>` objects, which provide:

- The ``objectType`` of the object the client attempted to write
- The ``primaryKey`` of the specific object
- The ``reason`` for the compensating write error

This information is the same information you can find in the App Services logs.
It is exposed on the client for convenience and debugging purposes.

.. example::

This error handler shows an example of how you might log information
about compensating write errors:

.. literalinclude:: /examples/generated/code/start/Errors.snippet.access-compensating-write.swift
:language: swift

The example error handler above produces this output when a compensating
write error occurs:

.. code-block:: console
A write was rejected with a compensating write error
The write to object type: Optional("Item")
With primary key of: objectId(641382026852d9220b2e2bbf)
Was rejected because: Optional("write to \"641382026852d9220b2e2bbf\" in table \"Item\" not
allowed; object is outside of the current query view")
- The ``Optional("Item")`` in this message is an ``Item`` object used in the
:github:`Swift Template App <mongodb/template-app-swiftui-todo>`.
- The primary key is the ``objectId`` of the specific object the client
attempted to write.
- The ``table \"Item"\`` refers to the Atlas collection where this object
would sync.
- The reason ``object is outside of the current query view`` in this example
is because the query subscription was set to require the object's ``isComplete``
property to be ``true``, and the client attempted to write an object where
this property was ``false``.
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
The Node.js SDK exposes a ``writes`` field on a
:js-sdk:`CompensatingWriteError <classes/Realm.CompensatingWriteError.html>`.
You can access this information through the :ref:`Sync error handler
<sdks-handle-sync-errors>`.

This field contains an array of :js-sdk:`CompensatingWriteInfo
<types/Realm.CompensatingWriteInfo.html>` objects, which provide:

- The ``objectName`` of the object the client attempted to write
- The ``primaryKey`` of the specific object
- The ``reason`` for the compensating write error

This information is the same information you can find in the App Services logs.
It is exposed on the client for convenience and debugging purposes.
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
.. tabs-drivers::

tabs:
- id: cpp-sdk
content: |

.. literalinclude:: /examples/generated/cpp/sync-errors.snippet.compensating-write-model.cpp
:language: cpp

- id: csharp
content: |

.. literalinclude:: /examples/MissingPlaceholders/example.cs
:language: csharp

- id: dart
content: |

.. literalinclude:: /examples/generated/flutter/write_to_synced_realm_test.snippet.realm-model.dart
:language: dart

- id: javascript
content: |

.. literalinclude:: /examples/MissingPlaceholders/example.js
:language: javascript

- id: kotlin
content: |

.. literalinclude:: /examples/generated/kotlin/SyncedRealmCRUD.snippet.flexible-sync-crud-model.kt
:language: kotlin

- id: swift
content: |

.. literalinclude:: /examples/generated/code/start/SyncedRealmCRUD.snippet.flexible-sync-crud-model.swift
:language: swift

- id: typescript
content: |

.. literalinclude:: /examples/MissingPlaceholders/example.ts
:language: typescript
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
.. tabs-drivers::

tabs:
- id: cpp-sdk
content: |

.. literalinclude:: /examples/generated/cpp/sync-errors.snippet.compensating-write-setup.cpp
:language: cpp

- id: csharp
content: |

.. literalinclude:: /examples/generated/dotnet/FlexibleSyncExamples.snippet.example_sub.cs
:language: csharp
:copyable: false

- id: dart
content: |

.. literalinclude:: /examples/generated/flutter/write_to_synced_realm_test.snippet.subscription-setup.dart
:language: dart

- id: javascript
content: |

.. literalinclude:: /examples/MissingPlaceholders/example.js
:language: javascript

- id: kotlin
content: |

.. literalinclude:: /examples/generated/kotlin/SyncedRealmCRUD.snippet.flexible-sync-subscription-setup.kt
:language: kotlin

- id: swift
content: |

.. literalinclude:: /examples/generated/code/start/SyncedRealmCRUD.snippet.flexible-sync-subscription-setup.swift
:language: swift

- id: typescript
content: |

.. literalinclude:: /examples/MissingPlaceholders/example.ts
:language: typescript
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
.. tabs-drivers::

tabs:
- id: cpp-sdk
content: |

.. literalinclude:: /examples/generated/cpp/sync-errors.snippet.successful-write-example.cpp
:language: cpp

- id: csharp
content: |

.. literalinclude:: /examples/MissingPlaceholders/example.cs
:language: csharp

- id: dart
content: |

.. literalinclude:: /examples/generated/flutter/write_to_synced_realm_test.snippet.write-synced-realm.dart
:language: dart

- id: javascript
content: |

.. literalinclude:: /examples/MissingPlaceholders/example.js
:language: javascript

- id: kotlin
content: |

.. literalinclude:: /examples/generated/kotlin/SyncedRealmCRUD.snippet.successful-write.kt
:language: kotlin

- id: swift
content: |

.. literalinclude:: /examples/generated/code/start/SyncedRealmCRUD.snippet.successful-write.swift
:language: swift

- id: typescript
content: |

.. literalinclude:: /examples/MissingPlaceholders/example.ts
:language: typescript
Loading

0 comments on commit da08965

Please sign in to comment.