Skip to content

Commit a0659fc

Browse files
dacharyclindseymooreMongoCalebcbullinger
authored
(DOCSP-39539): Consolidate Stream Data to Atlas page (#3268)
## Pull Request Info - SDK Docs Consolidation Jira ticket: https://jira.mongodb.org/browse/DOCSP-39539 *Staged Page* - [Stream Data to Atlas](https://preview-mongodbdacharyc.gatsbyjs.io/realm/DOCSP-39539/sdk/sync/stream-data-to-atlas/): Draft consolidated page *Page Source* - [C++: Stream Data to Atlas](https://www.mongodb.com/docs/atlas/device-sdks/sdk/cpp/sync/stream-data-to-atlas/) - [Flutter: Stream Data to Atlas](https://www.mongodb.com/docs/atlas/device-sdks/sdk/flutter/sync/stream-data-to-atlas/) - [Kotlin: Stream Data to Atlas](https://www.mongodb.com/docs/atlas/device-sdks/sdk/kotlin/sync/stream-data-to-atlas/) - [.NET: Stream Data to Atlas](https://www.mongodb.com/docs/atlas/device-sdks/sdk/dotnet/sync/asymmetric-sync/) - [Node.js: Stream Data to Atlas](https://www.mongodb.com/docs/atlas/device-sdks/sdk/node/sync/stream-data-to-atlas/) - [Swift: Stream Data to Atlas](https://www.mongodb.com/docs/atlas/device-sdks/sdk/swift/sync/stream-data-to-atlas/) ### 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: - [ ] Shared code example boxes contain language-specific snippets or placeholders for every language - [ ] API reference details contain working API reference links or generic content - [ ] Realm naming/language has been updated - [ ] All relevant content from individual SDK pages is present on the consolidated page --------- Co-authored-by: lindseymoore <71525840+lindseymoore@users.noreply.github.com> Co-authored-by: MongoCaleb <caleb.thompson@mongodb.com> Co-authored-by: cbullinger <115956901+cbullinger@users.noreply.github.com>
1 parent 643a481 commit a0659fc

File tree

33 files changed

+516
-59
lines changed

33 files changed

+516
-59
lines changed

examples/dotnet/Examples/Asymmetrics.cs

Lines changed: 11 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -11,25 +11,26 @@ namespace Examples
1111
{
1212
public partial class Asymmetrics
1313
{
14-
App app;
15-
Realms.Sync.User user;
1614
Realm realm;
17-
const string myRealmAppId = Config.FSAppId;
15+
const string myAppId = Config.FSAppId;
1816

1917
[OneTimeSetUp]
2018
public void Setup()
2119
{
22-
app = App.Create(myRealmAppId);
23-
user = app.LogInAsync(
20+
// :snippet-start: connect-and-authenticate
21+
App app = App.Create(myAppId);
22+
Realms.Sync.User user = app.LogInAsync(
2423
Credentials.Anonymous()).Result;
25-
24+
// :snippet-end:
25+
26+
// :snippet-start: configure-and-open-db
2627
var config = new FlexibleSyncConfiguration(user)
2728
{
2829
Schema = new[] { typeof(Measurement) }
2930
};
3031

31-
3232
realm = Realm.GetInstance(config);
33+
// :snippet-end:
3334

3435
// You cannot add a subscription for an AsymmetricObject
3536
// This causes a compile-time error:
@@ -40,22 +41,18 @@ public void Setup()
4041
//});
4142
// :uncomment-end:
4243
}
43-
44-
// :snippet-start: asymmetry
45-
// :remove-start:
4644
[Realms.Explicit]
47-
// :remove-end:
45+
// :snippet-start: define-asymmetric-object
4846
private partial class Measurement : IAsymmetricObject
4947
{
5048
[PrimaryKey, MapTo("_id")]
5149
public Guid Id { get; private set; } = Guid.NewGuid();
5250
public double Value { get; set; }
5351
public DateTimeOffset Timestamp { get; private set; } = DateTimeOffset.UtcNow;
5452
}
55-
56-
// :remove-start:
53+
// :snippet-end:
5754
[Test]
58-
// :remove-end:
55+
// :snippet-start: asymmetry
5956
public void SendMeasurementToRealm()
6057
{
6158
var measurement = new Measurement

source/examples/generated/dotnet/Asymmetrics.snippet.asymmetry.cs

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,3 @@
1-
private partial class Measurement : IAsymmetricObject
2-
{
3-
[PrimaryKey, MapTo("_id")]
4-
public Guid Id { get; private set; } = Guid.NewGuid();
5-
public double Value { get; set; }
6-
public DateTimeOffset Timestamp { get; private set; } = DateTimeOffset.UtcNow;
7-
}
8-
91
public void SendMeasurementToRealm()
102
{
113
var measurement = new Measurement
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
var config = new FlexibleSyncConfiguration(user)
2+
{
3+
Schema = new[] { typeof(Measurement) }
4+
};
5+
6+
realm = Realm.GetInstance(config);
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
App app = App.Create(myAppId);
2+
Realms.Sync.User user = app.LogInAsync(
3+
Credentials.Anonymous()).Result;
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
private partial class Measurement : IAsymmetricObject
2+
{
3+
[PrimaryKey, MapTo("_id")]
4+
public Guid Id { get; private set; } = Guid.NewGuid();
5+
public double Value { get; set; }
6+
public DateTimeOffset Timestamp { get; private set; } = DateTimeOffset.UtcNow;
7+
}
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
Once you have an open database, you can create an ``asymmetric_object``
2+
and set its values as you would a regular object.
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
You can sync data unidirectionally when you declare an object's
2+
schema as a ``REALM_ASYMMETRIC_SCHEMA``.
3+
4+
For more information on how to define a ``REALM_ASYMMETRIC_SCHEMA``,
5+
including limitations when linking to other object types, refer to
6+
:ref:`Define an Asymmetric Object <sdks-asymmetric-objects>`.
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
Unlike opening a database for non-asymmetric object types, when you open a
2+
database for Data Ingest, you *must* specify the ``asymmetric_object`` types
3+
you want to sync.
4+
5+
.. tip:: Mixed Object and Asymmetric Object Types
6+
7+
You cannot open a single synced database to manage both regular objects
8+
and asymmetric objects. You must use different databases to manage these
9+
different object types.
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
The process for writing asymmetric objects is the same as standard
2+
bi-directional Sync. The following code shows creating an asymmetric object
3+
and syncing it with the backend. It also shows to queries that generate
4+
errors.
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
To define an asymmetric object, your objects must implement the
2+
:dotnet-sdk:`IAsymmetricObject <reference/Realms.IAsymmetricObject.html>`
3+
interface or derive from the
4+
:dotnet-sdk:`AsymmetricObject <reference/Realms.AsymmetricObject.html>` class.
5+
6+
For more information on how to define an asymmetric object, refer to
7+
:ref:`sdks-asymmetric-objects`.
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
Once you have an open database, you can create an asymmetric object inside
2+
a write transaction. Pass your object data to ``realm.ingest``.
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
To define an asymmetric object, pass ``ObjectType.asymmetricObject`` to
2+
``@RealmModel()``.
3+
4+
For more information on how to define an asymmetric object, refer to
5+
:ref:`sdks-asymmetric-objects`.
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
Once you have an open database, you can create an asymmetric object inside
2+
a write transaction using :js-sdk:`Realm.create() <classes/Realm-1.html#create>`.
3+
When creating an asymmetric object, ``Realm.create()`` returns
4+
``undefined`` rather than the object itself.
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
Asymmetric objects sync data unidirectionally. Define an asymmetric object
2+
by setting ``asymmetric`` to ``true`` in your object schema. For more
3+
information, refer to the :js-sdk:`BaseObjectSchema API reference
4+
<types/BaseObjectSchema.html>`.
5+
6+
For more information on how to define an asymmetric object, refer to
7+
:ref:`Define an Asymmetric Object <sdks-asymmetric-objects>`.
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
Once you have an open database, you can create an ``AsymmetricRealmObject``
2+
inside a write transaction using the :kotlin-sync-sdk:`insert() <io.realm.kotlin.mongodb.ext/insert.html>`
3+
extension method:
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
You can sync data unidirectionally when that object is an
2+
``AsymmetricRealmObject``.
3+
4+
Define an asymmetric object by implementing the
5+
:kotlin-sync-sdk:`AsymmetricRealmObject <io.realm.kotlin.types/-asymmetric-realm-object/index.html>`
6+
interface.
7+
8+
.. include:: /includes/kotlin-asymmetric-object.rst
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
Specify the ``AsymmetricRealmObject`` types you want to sync.
2+
3+
If you have non-asymmetric objects in the same database, you can add a
4+
Sync subscription query for only those objects.
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
Once you have an open database, you can create an ``AsymmetricObject`` inside
2+
a write transaction using :swift-sdk:`create(_ type:, value:)
3+
<Structs/Realm.html#/s:10RealmSwift0A0V6create_5valueyxm_yptSo0aB16AsymmetricObjectCRbzlF>`.
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
You can sync data unidirectionally when that object is an ``AsymmetricObject``.
2+
Define an AsymmetricObject by deriving from :swift-sdk:`AsymmetricObject
3+
<Extensions/AsymmetricObject.html>`.
4+
5+
For more information on how to define an ``AsymmetricObject``, refer to
6+
:ref:`Define an AsymmetricObject <sdks-asymmetric-objects>`.
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
Specify the ``AsymmetricObject`` types you want to sync.
2+
3+
.. note:: Mixed Synced and Non-Synced Databases in Projects
4+
5+
The ``AsymmetricObject`` type is incompatible with non-synced databases.
6+
If your project uses both a synced and non-synced database, you must
7+
explicitly :ref:`pass a subset of classes in your database configuration
8+
<sdks-provide-a-subset-of-classes-to-a-database>` to exclude the
9+
``AsymmetricObject`` from your non-synced database.
10+
11+
Automatic schema discovery means that opening a non-synced database
12+
without specifically excluding the ``AsymmetricObject`` from the
13+
configuration can throw an error related to trying to use an
14+
incompatible object type.

source/includes/data-ingest-overview.rst

Lines changed: 0 additions & 12 deletions
This file was deleted.
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
When defining an asymmetric object in C#:
2+
3+
- The C# objects that you sync with Atlas must implement the
4+
:dotnet-sdk:`IAsymmetricObject <reference/Realms.IAsymmetricObject.html>`
5+
interface or derive from the
6+
:dotnet-sdk:`AsymmetricObject <reference/Realms.AsymmetricObject.html>` class.
7+
8+
- Starting in .NET SDK version 11.6.0 and later, an object that implements
9+
``IAsymmetricObject`` can contain
10+
:dotnet-sdk:`IEmbeddedObject <reference/Realms.IEmbeddedObject.html>` types,
11+
and links to ``IRealmObject`` types. In .NET SDK versions 11.5.0 and earlier,
12+
an object that implements ``IAsymmetricObject`` can only contain
13+
:dotnet-sdk:`IEmbeddedObject <reference/Realms.IEmbeddedObject.html>` types -
14+
it does not support links to ``IRealmObject`` types or other
15+
``IAsymmetricObject`` types.
16+
17+
- ``IRealmObject`` and ``IEmbeddedObject`` types cannot contain ``IAsymmetricObject``
18+
types as properties.
Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,16 @@
11
Asymmetric objects broadly support the same property types as ``RealmObject``,
22
with a few exceptions:
33

4-
- Asymmetric objects can only be used in synced realms configured with
5-
Flexible Sync. However, you cannot create subscriptions to
6-
asymmetric objects.
4+
- Asymmetric objects can only be used in synced databases. However, you cannot
5+
create subscriptions to asymmetric objects.
76
- An ``AsymmetricRealmObject`` can contain ``EmbeddedRealmObject``
87
types, but *cannot* contain ``RealmObject`` types or other
98
``AsymmetricRealmObject`` types.
109
- ``AsymmetricRealmObject`` types *cannot* be used as properties in other
11-
Realm objects.
10+
database objects.
1211

13-
Additionally, asymmetric objects do not function in the same way as other Realm objects.
14-
You cannot add, read, update, or delete an asymmetric object from the realm.
15-
You can only create an asymmetric object, which then syncs unidirectionally
16-
to the Atlas database linked to your App with Device Sync.
17-
Realm then deletes this object after syncing.
12+
Additionally, asymmetric objects do not function in the same way as other
13+
database objects. You cannot add, read, update, or delete an asymmetric object
14+
from the database. You can only create an asymmetric object, which then syncs
15+
unidirectionally to the Atlas database linked to your App with Device Sync.
16+
The SDK then deletes this object after syncing.
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
.. tabs-drivers::
2+
3+
tabs:
4+
- id: cpp-sdk
5+
content: |
6+
7+
.. literalinclude:: /examples/generated/cpp/asymmetric-sync.snippet.connect-and-authenticate.cpp
8+
:language: cpp
9+
10+
- id: csharp
11+
content: |
12+
13+
.. literalinclude:: /examples/generated/dotnet/Asymmetrics.snippet.connect-and-authenticate.cs
14+
:language: csharp
15+
16+
- id: dart
17+
content: |
18+
19+
.. literalinclude:: /examples/generated/flutter/app_services_test.snippet.access-app-client.dart
20+
:language: dart
21+
22+
.. literalinclude:: /examples/generated/flutter/authenticate_users_test.snippet.anonymous-credentials.dart
23+
:language: dart
24+
25+
- id: javascript
26+
content: |
27+
28+
.. literalinclude:: /examples/generated/node/authenticate.snippet.anonymous-login.js
29+
:language: javascript
30+
31+
- id: kotlin
32+
content: |
33+
34+
.. literalinclude:: /examples/generated/kotlin/AsymmetricSyncTest.snippet.connect-and-authenticate.kt
35+
:language: kotlin
36+
37+
- id: swift
38+
content: |
39+
40+
.. literalinclude:: /examples/generated/code/start/AsymmetricSync.snippet.connect-and-authenticate.swift
41+
:language: swift
42+
43+
- id: typescript
44+
content: |
45+
46+
.. literalinclude:: /examples/generated/node/authenticate.snippet.anonymous-login.ts
47+
: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/asymmetric-sync.snippet.create-asymmetric-object.cpp
8+
:language: cpp
9+
10+
- id: csharp
11+
content: |
12+
13+
.. literalinclude:: /examples/generated/dotnet/Asymmetrics.snippet.asymmetry.cs
14+
:language: csharp
15+
16+
- id: dart
17+
content: |
18+
19+
.. literalinclude:: /examples/generated/flutter/data_ingest.test.snippet.write-asymmetric-object.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/AsymmetricSyncTest.snippet.create-asymmetric-object.kt
32+
:language: kotlin
33+
34+
- id: swift
35+
content: |
36+
37+
.. literalinclude:: /examples/generated/code/start/AsymmetricSync.snippet.create-asymmetric-object.swift
38+
:language: swift
39+
40+
- id: typescript
41+
content: |
42+
43+
.. literalinclude:: /examples/generated/node/asymmetric-sync.snippet.write-asymmetric-object.ts
44+
:language: typescript
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
.. tabs-drivers::
2+
3+
tabs:
4+
- id: cpp-sdk
5+
content: |
6+
7+
.. literalinclude:: /examples/generated/cpp/asymmetric-sync.snippet.asymmetric-object.cpp
8+
:language: cpp
9+
10+
- id: csharp
11+
content: |
12+
13+
.. literalinclude:: /examples/generated/dotnet/Asymmetrics.snippet.define-asymmetric-object.cs
14+
:language: csharp
15+
16+
- id: dart
17+
content: |
18+
19+
.. literalinclude:: /examples/generated/flutter/data_ingest.test.snippet.asymmetric-sync-object.dart
20+
:language: dart
21+
:emphasize-lines: 1
22+
23+
- id: javascript
24+
content: |
25+
26+
.. literalinclude:: /examples/generated/node/asymmetric-sync.snippet.asymmetric-sync-object.js
27+
:language: javascript
28+
:emphasize-lines: 6
29+
30+
- id: kotlin
31+
content: |
32+
33+
.. literalinclude:: /examples/generated/kotlin/Schema.snippet.define-asymmetric-model.kt
34+
:language: kotlin
35+
36+
- id: swift
37+
content: |
38+
39+
.. literalinclude:: /examples/generated/code/start/AsymmetricSync.snippet.asymmetric-model.swift
40+
:language: swift
41+
42+
- id: typescript
43+
content: |
44+
45+
.. literalinclude:: /examples/generated/node/asymmetric-sync.snippet.asymmetric-sync-object.ts
46+
:language: typescript
47+
:emphasize-lines: 12

0 commit comments

Comments
 (0)