Skip to content

Commit 7a5d08f

Browse files
committed
Apply feedback
1 parent 68f8d77 commit 7a5d08f

File tree

15 files changed

+349
-316
lines changed

15 files changed

+349
-316
lines changed

source/sdk/dotnet/model-data/data-types/realm-value.txt

Lines changed: 15 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,7 @@ RealmValue - .NET SDK
1010
:depth: 2
1111
:class: singlecol
1212

13-
.. versionchanged:: 12.2.0
14-
15-
``RealmValue`` can hold lists and dictionaries of mixed data.
13+
*Changed in version 12.2.0:* ``RealmValue`` can hold lists and dictionaries of mixed data.
1614

1715
The ``RealmValue`` data type is a mixed data type, and can represent any
1816
other valid Realm data type except an embedded object or a set. You can create collections
@@ -39,23 +37,20 @@ that property:
3937

4038
.. _dotnet-nested-collections-realm-value:
4139

42-
Nested Collections of RealmValue
43-
--------------------------------
44-
45-
.. versionadded:: 12.22.0
46-
47-
Starting with .NET SDK v12.22.0, a ``RealmValue`` data type can
48-
hold collections (a list or dictionary, but *not* a set) of ``RealmValue`` elements.
40+
Mixed Collections
41+
-----------------
4942

50-
These collections of mixed data can be nested and can contain other
51-
collections. They can also be
52-
:ref:`listened to for changes <dotnet-collection-notifications>` like a
53-
normal collection.
43+
In version 12.22.0 and later, a ``RealmValue`` data type can hold collections
44+
(a list or dictionary, but *not* a set) of ``RealmValue`` elements. You can use
45+
mixed collections to model unstructured or variable data. For more information,
46+
refer to :ref:`<dotnet-model-unstructured-data>`.
5447

55-
You can leverage these nested collections to define unstructured
56-
or variable data in your data model. For more information, refer to
57-
:ref:`<dotnet-model-unstructured-data>`.
48+
- You can nest mixed collections up to 100 levels.
49+
- You can query mixed collection properties and
50+
:ref:`register a listener for changes <dotnet-collection-notifications>`,
51+
as you would a normal collection.
52+
- You can find and update individual mixed collection elements
53+
- You *cannot* store sets or embedded objects in mixed collections.
5854

59-
To create nested collections of mixed data in your app, define the mixed type
60-
property in your data model the same way you would any other ``RealmValue`` type.
61-
Then, you can set the property as a list or dictionary.
55+
To use mixed collections, define the ``RealmValue`` type property in your data model.
56+
Then, set the property as a list or dictionary.

source/sdk/dotnet/model-data/define-object-model.txt

Lines changed: 29 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -266,26 +266,35 @@ Model Unstructured Data
266266

267267
.. versionadded:: 12.22.0
268268

269-
Starting in .NET SDK version 12.22.0, you can
270-
:ref:`define nested collections of mixed data <dotnet-nested-collections-realm-value>`
271-
within a ``RealmValue`` property.
272-
273-
The ability to nest collections of mixed data enables you to define data
274-
that doesn't otherwise conform to an expected schema, including data with
275-
variable structure or data whose shape or type is not known at runtime.
276-
For example, you might have highly variable user-created objects, event logs,
277-
or survey response data that are collected and stored in a variety of JSON
278-
formats. This approach allows you to :ref:`react to changes <dotnet-collection-notifications>`
279-
in the nested data and to update specific elements, but it is less
280-
performant than using a structured schema or serializing JSON blobs
281-
into a single string property.
282-
283-
To model unstructured data in your schema using collections of mixed type,
284-
define the appropriate properties in your schema as
285-
:ref:`RealmValue <realmvalue>` types. You can then set these
286-
``RealmValue`` properties as a :ref:`list <dotnet-property-lists>` or a
287-
:ref:`dictionary <dotnet-client-dictionaries>` collection of ``RealmValue`` elements.
288-
Note that ``RealmValue`` *cannot* represent a set or an embedded object.
269+
Starting in SDK version 12.22.0, you can store :ref:`collections of mixed data <dotnet-nested-collections-realm-value>`
270+
within a ``RealmValue`` property. You can use this feature to model complex data
271+
structures, such as JSON or MongoDB documents, without having to define a
272+
strict data model.
273+
274+
**Unstructured data** is data that doesn't easily conform to an expected
275+
schema, making it difficult or impractical to model to individual
276+
data classes. For example, your app might have highly variable data or dynamic
277+
data whose structure is unknown at runtime.
278+
279+
Storing collections in a mixed property offers flexibility without sacrificing
280+
functionality, including performant synchronization when using Device Sync. And
281+
you can work with them the same way you would a non-mixed
282+
collection:
283+
284+
- You can nest mixed collections up to 100 levels.
285+
- You can query on and :ref:`react to changes
286+
<dotnet-collection-notifications>` on mixed collections.
287+
- You can find and update individual mixed collection elements.
288+
289+
However, storing data in mixed collections is less performant than using a structured
290+
schema or serializing JSON blobs into a single string property.
291+
292+
To model unstructured data in your app, define the appropriate properties in
293+
your schema as :ref:`RealmValue <realmvalue>` types. You can then
294+
set these ``RealmValue`` properties as a :ref:`list <dotnet-property-lists>` or a
295+
:ref:`dictionary <dotnet-client-dictionaries>` of ``RealmValue`` elements.
296+
Note that ``RealmValue`` *cannot* represent a set or an embedded
297+
object.
289298

290299
.. tip::
291300

source/sdk/flutter/realm-database/model-data/data-types.txt

Lines changed: 16 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -438,25 +438,26 @@ data type.
438438

439439
.. _flutter-nested-collections-realm-value:
440440

441-
Nested Collections of RealmValue
442-
````````````````````````````````
441+
Mixed Collections
442+
`````````````````
443443

444-
.. versionadded:: 2.0.0
444+
*Changed in version 2.0.0:* ``RealmValue`` properties can
445+
contain lists or maps of mixed data.
445446

446-
Starting with Flutter SDK v2.0.0, a ``RealmValue`` data type can
447-
contain collections (a list or map, but *not* a set) of ``RealmValue`` elements.
448-
449-
These collections of mixed data can be nested and can contain other
450-
collections. They can also be :ref:`listened to for changes like a
451-
normal collection <flutter-realm-list-change-listener>`.
452-
453-
You can leverage these nested collections to define unstructured
454-
or variable data in your data model. For more information, refer to
447+
In version 2.0.0 and later, a mixed data type can hold collections (a list or
448+
map, but *not* a set) of mixed elements. You can use mixed collections to
449+
model unstructured or variable data. For more information, refer to
455450
:ref:`<flutter-model-unstructured-data>`.
456451

457-
To create nested collections of mixed data in your app, define the mixed type
458-
property in your data model the same way you would any other ``RealmValue`` type.
459-
Then, you can create the list or map collections using ``RealmValue.from()``.
452+
- You can nest mixed collections up to 100 levels.
453+
- You can query mixed collection properties and
454+
:ref:`register a listener for changes <flutter-realm-list-change-listener>`,
455+
as you would a normal collection.
456+
- You can find and update individual mixed collection elements
457+
- You *cannot* store sets or embedded objects in mixed collections.
458+
459+
To use mixed collections, define the mixed type property in your data model.
460+
Then, create the list or map collections using ``RealmValue.from()``.
460461

461462
.. literalinclude:: /examples/generated/flutter/data_types_test.snippet.realm-value-nested-collections.dart
462463
:language: dart

source/sdk/flutter/realm-database/model-data/define-realm-object-schema.txt

Lines changed: 50 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
Define a Realm Object Schema - Flutter SDK
55
==========================================
66

7-
.. meta::
7+
.. meta::
88
:keywords: code example, android, ios, data modeling
99
:description: Define the properties and relationships of database objects within your data model.
1010

@@ -62,8 +62,8 @@ Create Model
6262
.. step:: Create Generated File Part Directive
6363

6464
.. versionchanged:: v2.0.0
65-
Generated files are named ``.realm.dart`` instead of ``.g.dart``
66-
65+
Generated files are named ``.realm.dart`` instead of ``.g.dart``
66+
6767
Add a part directive to include the ``RealmObject`` file that you generate in step 4
6868
in the same package as the file you're currently working on.
6969

@@ -96,13 +96,13 @@ Create Model
9696
.. literalinclude:: /examples/generated/flutter/schemas.snippet.create-realm-model.dart
9797
:language: dart
9898
:caption: schemas.dart
99-
99+
100100
.. include:: /includes/note-class-char-limit.rst
101101

102102
.. step:: Generate RealmObject
103103

104104
.. versionchanged:: v2.0.0
105-
Generated files are named ``.realm.dart`` instead of ``.g.dart``
105+
Generated files are named ``.realm.dart`` instead of ``.g.dart``
106106

107107
Generate the ``RealmObject``, which you'll use in your application:
108108

@@ -211,19 +211,19 @@ Map a Model or Class to a Different Name
211211
----------------------------------------
212212

213213
You can use the `MapTo <https://pub.dev/documentation/realm_common/latest/realm_common/MapTo-class.html>`__
214-
annotation to map a Realm object model or property to a different stored
214+
annotation to map a Realm object model or property to a different stored
215215
name in Realm. This can be useful in the following scenarios. For example:
216216

217-
- To make it easier to work across platforms where naming conventions
218-
differ. For example, if your Device Sync schema property names use snake
217+
- To make it easier to work across platforms where naming conventions
218+
differ. For example, if your Device Sync schema property names use snake
219219
case, while your project uses camel case.
220220
- To change a class or field name without forcing a migration.
221221
- To support multiple model classes with the same name in different packages.
222-
- To use a class name that is longer than the 57-character limit enforced
222+
- To use a class name that is longer than the 57-character limit enforced
223223
by Realm.
224224

225-
If you're using Atlas Device Sync, the name that you specify in the
226-
``MapTo`` annotation is used as the persisted :ref:`App Services Schema
225+
If you're using Atlas Device Sync, the name that you specify in the
226+
``MapTo`` annotation is used as the persisted :ref:`App Services Schema
227227
<schemas>` name.
228228

229229
.. tabs::
@@ -244,40 +244,48 @@ If you're using Atlas Device Sync, the name that you specify in the
244244

245245
.. _flutter-model-unstructured-data:
246246

247-
Model Unstructured Data
247+
Model Unstructured Data
248248
-----------------------
249249

250250
.. versionadded:: 2.0.0
251251

252-
Starting in Flutter SDK version 2.0.0, you can
253-
:ref:`define nested collections
254-
of mixed data <flutter-nested-collections-realm-value>`
255-
within a ``RealmValue`` property.
256-
257-
The ability to nest collections of mixed data enables you to define data
258-
that doesn't otherwise conform to an expected schema, including data with
259-
variable structure or data whose shape or type is not known at runtime.
260-
For example, you might have highly variable user-created objects, event logs,
261-
or survey response data that are collected and stored in a variety of JSON
262-
formats. This approach allows you to :ref:`react to changes <flutter-realm-list-change-listener>`
263-
in the nested data and to update specific elements, but it is less
264-
performant than using a structured schema or serializing JSON blobs
265-
into a single string property.
266-
267-
To model unstructured data in your schema using collections of mixed type,
268-
define the appropriate properties in your schema as
269-
:ref:`RealmValue <flutter-realm-value>` types. You can then set these
270-
``RealmValue`` properties as a :ref:`RealmList <flutter-realm-list>` or a
271-
:ref:`RealmMap <flutter-realm-map>` collection of ``RealmValue`` elements.
252+
Starting in Flutter SDK version 2.0.0, you can store
253+
:ref:`collections of mixed data <flutter-nested-collections-realm-value>`
254+
within a ``RealmValue`` property. You can use this feature to model complex
255+
data structures, such as JSON or MongoDB documents, without having to define a
256+
strict data model.
257+
258+
**Unstructured data** is data that doesn't easily conform to an expected
259+
schema, making it difficult or impractical to model to individual
260+
data classes. For example, your app might have highly variable data or dynamic
261+
data whose structure is unknown at runtime.
262+
263+
Storing collections in a mixed property offers flexibility without sacrificing
264+
functionality, including performant synchronization when using Device Sync. And
265+
you can work with them the same way you would a non-mixed
266+
collection:
267+
268+
- You can nest mixed collections up to 100 levels.
269+
- You can query on and :ref:`react to changes <flutter-realm-list-change-listener>`
270+
on mixed collections.
271+
- You can find and update individual mixed collection elements.
272+
273+
However, storing data in mixed collections is less performant than using a structured
274+
schema or serializing JSON blobs into a single string property.
275+
276+
To model unstructured data in your app, define the appropriate properties in
277+
your schema as :ref:`RealmValue <flutter-realm-value>` types. You can then set
278+
these ``RealmValue`` properties as a :ref:`RealmList <flutter-realm-list>` or a
279+
:ref:`RealmMap <flutter-realm-map>` collection of ``RealmValue`` elements.
272280
Note that ``RealmValue`` *cannot* represent a ``RealmSet`` or an embedded object.
273281

274-
For example, you might use a ``RealmValue`` that contains a map of mixed
275-
data when modeling a variable event log object:
282+
For example, you might use a ``RealmValue`` that contains a map of mixed
283+
data when modeling a variable event log object:
276284

277285
.. literalinclude:: /examples/generated/flutter/define_realm_model_test.snippet.unstructured-data-model.dart
278286
:language: dart
279287
:emphasize-lines: 10
280-
:caption: Data model
288+
:caption: Data model
281289

282290
.. io-code-block::
283291
:copyable: true
@@ -286,7 +294,7 @@ data when modeling a variable event log object:
286294
.. input:: /examples/generated/flutter/define_realm_model_test.snippet.create-unstructured-data-example.dart
287295
:language: dart
288296

289-
.. output::
297+
.. output::
290298
:language: shell
291299

292300
Event Type: purchase
@@ -298,9 +306,9 @@ data when modeling a variable event log object:
298306
items: RealmValue([RealmValue({id: RealmValue(1), name: RealmValue(Laptop), price: RealmValue(1200.0)}), RealmValue({id: RealmValue(2), name: RealmValue(Mouse), price: RealmValue(49.99)})])
299307
total: RealmValue(1249.99)
300308

301-
.. tip::
309+
.. tip::
302310

303-
- Use a map of mixed data types when the type is unknown but each value will have a unique identifier.
311+
- Use a map of mixed data types when the type is unknown but each value will have a unique identifier.
304312
- Use a list of mixed data types when the type is unknown but the order of objects is meaningful.
305313

306314
.. _flutter-generate-realm-object:
@@ -309,10 +317,10 @@ Generate the RealmObject
309317
------------------------
310318

311319
.. versionchanged:: v2.0.0
312-
Generated files are named ``.realm.dart`` instead of ``.g.dart``
320+
Generated files are named ``.realm.dart`` instead of ``.g.dart``
313321

314322
Once you've completed your Realm model, you must generate the
315-
:flutter-sdk:`RealmObject <realm/RealmObjectBase-mixin.html>` class to use
323+
:flutter-sdk:`RealmObject <realm/RealmObjectBase-mixin.html>` class to use
316324
it in your application.
317325

318326
Run the following command to generate ``RealmObjects``:
@@ -410,7 +418,7 @@ Asymmetric objects require Flexible Sync. To define an asymmetric object, pass
410418

411419
In Flutter SDK versions 1.5.0 and earlier, you cannot link from
412420
``asymmetricObject`` types to ``RealmObjects``. In SDK versions 1.6.0 and
413-
later, ``asymmetricObject`` types can link to ``RealmObjects`` in
421+
later, ``asymmetricObject`` types can link to ``RealmObjects`` in
414422
addition to :ref:`embedded object types <flutter-embedded-objects>`.
415423

416424
.. note:: Attempting to Read Asymmetric Objects
@@ -419,5 +427,5 @@ addition to :ref:`embedded object types <flutter-embedded-objects>`.
419427
object, you will get the following error: "Error: You can't query an
420428
asymmetric class.".
421429

422-
To learn more about Data Ingest, refer to :ref:`Stream Data to Atlas
430+
To learn more about Data Ingest, refer to :ref:`Stream Data to Atlas
423431
<flutter-stream-data-to-atlas>`.

0 commit comments

Comments
 (0)