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

Conversion to Synced Realm only supported in PBS. #3333

Merged
merged 4 commits into from
Jul 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 8 additions & 3 deletions config/redirects
Original file line number Diff line number Diff line change
Expand Up @@ -1020,7 +1020,7 @@ raw: ${prefix}/sdk/dotnet/fundamentals/device-sync -> ${base}/sdk/dotnet/sync/
raw: ${prefix}/sdk/dotnet/fundamentals/asymmetric-sync -> ${base}/sdk/dotnet/sync/asymmetric-sync/
raw: ${prefix}/sdk/dotnet/advanced-guides/client-reset -> ${base}/sdk/dotnet/sync/client-reset/
raw: ${prefix}/sdk/dotnet/examples/open-a-realm -> ${base}/sdk/dotnet/sync/configure-and-open-a-synced-realm/
raw: ${prefix}/sdk/dotnet/advanced-guides/convert-realm -> ${base}/sdk/dotnet/sync/convert-realm/
raw: ${prefix}/sdk/dotnet/advanced-guides/convert-realm -> ${base}/sdk/dotnet/sync/configure-and-open-a-synced-realm
raw: ${prefix}/sdk/dotnet/examples/flexible-sync -> ${base}/sdk/dotnet/sync/flexible-sync/
raw: ${prefix}/sdk/dotnet/examples/work-with-users -> ${base}/sdk/dotnet/work-with-users/
raw: ${prefix}/sdk/dotnet/advanced-guides -> ${base}/sdk/dotnet/
Expand Down Expand Up @@ -1292,10 +1292,15 @@ raw: ${prefix}/sdk/node/integrations/electron-cra -> ${base}/sdk/node/
raw: ${prefix}/sdk/node/integrations/electron -> ${base}/sdk/node/
raw: ${prefix}/sdk/node/integrations -> ${base}/sdk/node/

# DOP-4255 Rehoming /docs/realm docs at /docs/atlas/device-sdks
# DOP-4452 Rehoming /docs/realm docs at /docs/atlas/device-sdks
raw: ${prefix} -> ${deviceSDKsBase}/
raw: ${prefix}/introduction -> ${deviceSDKsBase}/introduction/
raw: ${prefix}/realm-query-language -> ${deviceSDKsBase}/realm-query-language/
raw: ${prefix}/example-projects -> ${deviceSDKsBase}/example-projects/
raw: ${prefix}/help -> ${deviceSDKsBase}/help/
raw: ${prefix}/migrate -> ${deviceSDKsBase}/migrate/
raw: ${prefix}/migrate -> ${deviceSDKsBase}/migrate/

# DOCSP-39075
# No clarity from DOP on whether to use ${deviceSDKsBase} or ${base}, so going
# with what we know works (${base}).
raw: ${prefix}/sdk/dotnet/sync/convert-realm -> ${base}/sdk/dotnet/sync/configure-and-open-a-synced-realm
2 changes: 1 addition & 1 deletion examples/dotnet/Examples/Convert.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ public async Task TestNoSyncToSync()
var app = App.Create("my-app-id");
var user = await app.LogInAsync(
Credentials.EmailPassword("email@example.com", "password"));
var syncConfig = new FlexibleSyncConfiguration(user);
var syncConfig = new PartitionSyncConfiguration("user_partition", user);

existingRealm.WriteCopy(syncConfig);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
var app = App.Create("my-app-id");
var user = await app.LogInAsync(
Credentials.EmailPassword("email@example.com", "password"));
var syncConfig = new FlexibleSyncConfiguration(user);
var syncConfig = new PartitionSyncConfiguration("user_partition", user);

existingRealm.WriteCopy(syncConfig);

Expand Down
1 change: 0 additions & 1 deletion source/sdk/dotnet/sync.txt
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ Sync Data Between Devices - .NET SDK
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>
Convert Between Non-Synced Realms and Synced Realms </sdk/dotnet/sync/convert-realm>
Stream Data to Atlas </sdk/dotnet/sync/asymmetric-sync>
Partition-Based Sync </sdk/dotnet/sync/partition-based-sync>

Expand Down
19 changes: 9 additions & 10 deletions source/sdk/dotnet/sync/configure-and-open-a-synced-realm.txt
Original file line number Diff line number Diff line change
Expand Up @@ -48,16 +48,15 @@ and vice versa, but you cannot sync a non-synced realm.
.. _convert-realm-sync:

Convert Between Synced and Non-Synced Realms
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Realm does not have a direct mechanism to add sync to a non-synced realm,
or to permanently stop Sync for a synced realm. However, the .NET SDK does
provide methods that enable you to copy a realm file for use with a different
configuration. With these methods, you can easily duplicate a realm's data,
which you can then open with a sync or non-sync configuration. This lets
you indirectly add Sync to a non-synced realm, or permanently stop a realm
from syncing. For more information, refer to :ref:`<dotnet-convert-to-sync>`.

````````````````````````````````````````````
To convert a non-synced realm to a synced realm, you can follow the process
described in :ref:`Migrate a Local-Only App to a Sync-Enabled App <realm-sync-local-to-sync>`.
The .NET SDK also provides the
Copy link
Collaborator

Choose a reason for hiding this comment

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

I think we should either leave this off the page entirely, or mention here that it only works with Partition-Based Sync. Mentioning that this API exists without the warning that our "default" Sync apps can't use it feels like it will lead to user frustration.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Agreed. Added back in the note that was on the original page.

:dotnet-sdk:`WriteCopy() <reference/Realms.Realm.html#Realms_Realm_WriteCopy_Realms_RealmConfigurationBase_>`
method, which enables you to duplicate a non-synced realm's data to a sync realm.
For more information, refer to :ref:`<dotnet-convert-to-sync>`.

.. include:: /includes/note-writecopy-local-to-sync.rst

Synced Realms
~~~~~~~~~~~~~
Expand Down
70 changes: 0 additions & 70 deletions source/sdk/dotnet/sync/convert-realm.txt

This file was deleted.

25 changes: 24 additions & 1 deletion source/sdk/dotnet/sync/partition-based-sync.txt
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,6 @@ method:

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


Open a Partition-Based Sync Realm While Offline
-----------------------------------------------

Expand Down Expand Up @@ -163,3 +162,27 @@ codebase for future iteration and debugging.

For more information about the automatically-generated Flexible Sync
subscriptions, refer to :ref:`realm-sync-migrate-client`.

.. _dotnet-convert-to-sync:

Migrate from Non-Synced Realms to Synced Realms
-----------------------------------------------
You can convert a non-synced realm to a synced realm (with partition-based sync).
To convert from a non-synced realm to one that uses partition-based sync, you do
the following:

1. Open the existing realm.
2. Create a configuration for a new realm.
3. Call the :dotnet-sdk:`WriteCopy() <reference/Realms.Realm.html#Realms_Realm_WriteCopy_Realms_RealmConfigurationBase_>`
method on the existing realm to copy the data to the new realm.

In the following code, we open a non-synced realm, create a new
:dotnet-sdk:`PartitionSyncConfiguration <reference/Realms.Sync.PartitionSyncConfiguration.html>`
object and then copy the existing realm to the new realm. We then delete the
existing realm and open the new realm.

.. literalinclude:: /examples/generated/dotnet/Convert.snippet.nonsync-to-sync.cs
:language: csharp
:copyable: true

.. include:: /includes/note-writecopy-local-to-sync.rst
4 changes: 3 additions & 1 deletion source/sdk/flutter/sync.txt
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,9 @@ Synced realms differ from non-synced local Realm in a couple of ways:
realms have no concept of users or authentication.

You can copy data from a non-synced realm to a synced realm,
and vice versa, but you cannot sync a non-synced realm.
and vice versa, but you cannot sync a non-synced realm. To convert a non-synced
realm to a synced realm, you can follow the process
described in :ref:`Migrate a Local-Only App to a Sync-Enabled App <realm-sync-local-to-sync>`.

.. _flutter-flexible-sync-fundamentals:

Expand Down
4 changes: 3 additions & 1 deletion source/sdk/swift/sync/configure-and-open-a-synced-realm.txt
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,9 @@ few ways:
be used offline.

You can copy data from a non-synced realm to a synced realm,
and vice versa, but you cannot sync a non-synced realm.
and vice versa, but you cannot sync a non-synced realm. To convert a
non-synced realm to a synced realm, you can follow the process
described in :ref:`Migrate a Local-Only App to a Sync-Enabled App <realm-sync-local-to-sync>`.

For more information about how to configure and open a non-synced realm,
refer to: :ref:`ios-configure-and-open-a-realm`.
Expand Down
Loading