Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

(DOCSP-31531): NET SDK Migrate PBS to FS updates #2916

Merged
merged 12 commits into from
Aug 1, 2023

This file was deleted.

44 changes: 12 additions & 32 deletions source/sdk/dotnet/sync.txt
Original file line number Diff line number Diff line change
Expand Up @@ -15,46 +15,16 @@ Sync Data Between Devices - .NET SDK
Handle Sync Errors and Timeouts </sdk/dotnet/sync/handle-sync-errors>
Client Resets </sdk/dotnet/sync/client-reset>
Suspend or Resume a Sync Session </sdk/dotnet/sync/sync-session>
Check Upload & Download Progress </sdk/dotnet/sync/sync-progress>
Monitor Sync Status </sdk/dotnet/sync/sync-progress>
Convert Between Non-Synced Realms and Synced Realms </sdk/dotnet/sync/convert-realm>
Stream Data to Atlas </sdk/dotnet/sync/asymmetric-sync>

Overview
--------
Partition-Based Sync </sdk/dotnet/sync/partition-based-sync>

Atlas Device Sync automatically synchronizes data between client applications and
an :ref:`Atlas App Services backend <realm-cloud>`. When a client
device is online, Sync asynchronously synchronizes data in a
background thread between the device and your backend App.

When you use Sync in your client application, your implementation must match
the Sync Mode you select in your backend App configuration. The Sync Mode
options are:

- Partition-Based Sync
- Flexible Sync

You can only use one Sync Mode for your application. You cannot mix
Partition-Based Sync and Flexible Sync within the same App.

.. seealso::

:ref:`enable-realm-sync`

.. _dotnet-partition-based-sync-fundamentals:

Partition-Based Sync
--------------------

When you select :ref:`Partition-Based Sync <partition-based-sync>` for your
backend App configuration, your client implementation must include a
partition value. This is the value of the :ref:`partition key
<partition-key>` field you select when you configure Partition-Based Sync.

The partition value determines which data the client application can access.

You pass in the partition value when you open a synced realm.

.. _dotnet-flexible-sync-fundamentals:

Flexible Sync
Expand Down Expand Up @@ -84,6 +54,14 @@ To use Flexible Sync in your client application, open a synced realm
with a Flexible Sync configuration. Then, manage subscriptions
to determine which documents to sync.

.. tip::

Device Sync supports two Sync Modes: Flexible Sync, and the older
Partition-Based Sync. If your App Services backend uses Partition-Based
Sync, refer to :ref:`dotnet-partition-based-sync`.

We recommend new apps use Flexible Sync.
dacharyc marked this conversation as resolved.
Show resolved Hide resolved

Group Updates for Improved Performance
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Expand All @@ -98,3 +76,5 @@ In this scenario, you can maximize sync performance by using
:ref:`Data Ingest <dotnet-data-ingest>` to stream
data from the client application to a Flexible Sync-enabled Atlas App Services
App.


52 changes: 15 additions & 37 deletions source/sdk/dotnet/sync/configure-and-open-a-synced-realm.txt
Original file line number Diff line number Diff line change
Expand Up @@ -101,46 +101,32 @@ With cached credentials, you can:
- Open a synced realm after downloading changes from your App.
This requires the user to have an active internet connection.

.. _dotnet-flexible-sync-open-realm:

Open a Synced Realm with a Flexible Sync Configuration
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

When you use Flexible Sync, pass the current user to a
:dotnet-sdk:`FlexibleSyncConfiguration <reference/Realms.Sync.FlexibleSyncConfiguration.html>`
object to open a synced realm.

.. literalinclude:: /examples/generated/dotnet-flexible-sync/FlexibleSyncExamples.snippet.open-a-flexible-synced-realm.cs
:language: csharp

.. important:: Flexible Sync Requires a Subscription

You can't use a Flexible Sync realm until you add at least one subscription.
To learn how to add subscriptions, see: :ref:`<dotnet-sync-add-subscription>`.

.. _dotnet-open-a-synced-realm:
.. _dotnet-partition-sync-open-realm:
.. _dotnet-flexible-sync-open-realm:

Open a Partition-Based Sync Realm While Online
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Open a Synced Realm While Online
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

The steps for opening a synced realm while online are:

1. Your app code walks the user through :ref:`authenticating <dotnet-authenticate>`.

#. Create a
:dotnet-sdk:`PartitionSyncConfiguration <reference/Realms.Sync.PartitionSyncConfiguration.html>`
object that includes the :ref:`partition name <partition-value>` and
the :dotnet-sdk:`User <reference/Realms.Sync.User.html>` object.
:dotnet-sdk:`FlexibleSyncConfiguration <reference/Realms.Sync.FlexibleSyncConfiguration.html>`
object that includes :dotnet-sdk:`User <reference/Realms.Sync.User.html>`
object.

#. Open a synced realm by calling the
:dotnet-sdk:`GetInstanceAsync() <reference/Realms.Realm.html#Realms_Realm_GetInstanceAsync_Realms_RealmConfigurationBase_System_Threading_CancellationToken_>`
method, passing in the ``PartitionSyncConfiguration`` object.
method.

#. If your FlexibleSyncConfiguration did not contain
:ref:`initial subscriptions <dotnet-initial-subscriptions>`,
:ref:`add a subscription <dotnet-add-subscription-to-set>`.

The following code demonstrates these steps:

.. literalinclude:: /examples/generated/dotnet/OpenARealmExamples.snippet.open-synced-realm.cs
:language: csharp
<ADD-FS-CODE-EXAMPLE-HERE>
dacharyc marked this conversation as resolved.
Show resolved Hide resolved

In the above example, the code shows how to open the realm *asynchronously*
by calling ``GetInstanceAsync()``. You can also open a realm *synchronously*
Expand All @@ -151,15 +137,8 @@ method:
.. literalinclude:: /examples/generated/dotnet/OpenARealmExamples.snippet.open-synced-realm-synchronously.cs
:language: csharp

.. seealso::

:ref:`Partitions <sync-partitions>`

:ref:`Partition Strategies <partition-strategies>`


Open a Partition-Based Sync Realm While Offline
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Open a Synced Realm While Offline
dacharyc marked this conversation as resolved.
Show resolved Hide resolved
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Once a user authenticates, the ``User`` object persists on the device until the
user logs off. This allows your app to
Expand All @@ -171,8 +150,7 @@ The following code shows how to check if there is an existing ``User`` object.
If none is found, it uses the process outlined about to obtain a user. If the
device already has a ``user``, it opens the synced realm with that user:

.. literalinclude:: /examples/generated/dotnet/OpenARealmExamples.snippet.check-if-offline.cs
:language: csharp
<ADD-FS-CODE-EXAMPLE-HERE>
dacharyc marked this conversation as resolved.
Show resolved Hide resolved

Configuring Timeouts with AppConfiguration
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Expand Down
3 changes: 3 additions & 0 deletions source/sdk/dotnet/sync/flexible-sync.txt
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,8 @@ You must have at least one subscription before you can read from or write
to the realm. You can create one or more initial subscriptions when you
configure Flexible Sync, or you can add subscriptions after initialization.

.. _dotnet-initial-subscriptions:

Bootstrap the Realm with Initial Subscriptions
``````````````````````````````````````````````

Expand All @@ -120,6 +122,7 @@ queries you want to use to bootstrap the realm, as shown in the following exampl
.. literalinclude:: /examples/generated/dotnet/FlexibleSyncExamples.snippet.bootstrap-a-subscription.cs
:language: csharp

.. _dotnet-add-subscription-to-set:

Add a Subscription
``````````````````
Expand Down
Loading
Loading