Skip to content

Commit ebc8e9d

Browse files
authored
(DOCSP-39502): Consolidate Define an Object Model page (#3314)
## Pull Request Info - SDK Docs Consolidation Jira ticket: https://jira.mongodb.org/browse/DOCSP-39502 *Staged Page* - [Define an SDK Object Model](https://preview-mongodbdacharyc.gatsbyjs.io/realm/DOCSP-39502/sdk/model-data/object-models/) *Page Source* Add links to every SDK's pages where you got the SDK-specific information: - [C++: Object Types and Schemas](https://www.mongodb.com/docs/atlas/device-sdks/sdk/cpp/model-data/object-models/) - [C++: Supported Data Types](https://www.mongodb.com/docs/atlas/device-sdks/sdk/cpp/model-data/supported-types/) - [Flutter: Model Data landing page](https://www.mongodb.com/docs/atlas/device-sdks/sdk/flutter/realm-database/model-data/) - [Flutter: Define a Realm Object Schema](https://www.mongodb.com/docs/atlas/device-sdks/sdk/flutter/realm-database/model-data/define-realm-object-schema/) - [Flutter: Property Annotations](https://www.mongodb.com/docs/atlas/device-sdks/sdk/flutter/realm-database/model-data/property-annotations/) - [Java: Model Data landing page](https://www.mongodb.com/docs/atlas/device-sdks/sdk/java/model-data/) - [Java: Define an Object Model](https://www.mongodb.com/docs/atlas/device-sdks/sdk/java/model-data/define-a-realm-object-model/) - [Java: Realm Files Landing page (Realm Schema)](https://www.mongodb.com/docs/atlas/device-sdks/sdk/java/realm-files/#realm-schema) - [Kotlin: Model Data -> Define an Object Model](https://www.mongodb.com/docs/atlas/device-sdks/sdk/kotlin/realm-database/schemas/define-realm-object-model/) - [Kotlin: Open & Close a Realm (realm schema)](https://www.mongodb.com/docs/atlas/device-sdks/sdk/kotlin/realm-database/open-and-close-a-realm/) - [Kotlin: Property Annotations](https://www.mongodb.com/docs/atlas/device-sdks/sdk/kotlin/realm-database/schemas/property-annotations/) - [.NET: Define an Object Model](https://www.mongodb.com/docs/atlas/device-sdks/sdk/dotnet/model-data/define-object-model/) - [.NET: Object Types and Schemas](https://www.mongodb.com/docs/atlas/device-sdks/sdk/dotnet/model-data/object-models-and-schemas/) - [.NET: Manually Define a Schema](https://www.mongodb.com/docs/atlas/device-sdks/sdk/dotnet/model-data/manual-schema/) - [.NET: Configure & Open a Realm (Class Subsets)](https://www.mongodb.com/docs/atlas/device-sdks/sdk/dotnet/realm-files/realms/#class-subsets) - [Node.js SDK: Model Data](https://www.mongodb.com/docs/atlas/device-sdks/sdk/node/model-data/) - [Node.js SDK: Define an Object Model](https://www.mongodb.com/docs/atlas/device-sdks/sdk/node/model-data/define-a-realm-object-model/) - [Node.js SDK: Open & Close a Realm (schemas)](https://www.mongodb.com/docs/atlas/device-sdks/sdk/node/realm-files/open-and-close-a-realm/) - [Swift SDK: Model Data](https://www.mongodb.com/docs/atlas/device-sdks/sdk/swift/model-data/) - [Swift SDK: Define an Object Model](https://www.mongodb.com/docs/atlas/device-sdks/sdk/swift/model-data/object-models/) ### 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: - [x] Shared code example boxes contain language-specific snippets or placeholders for every language - [x] API reference details contain working API reference links or generic content - [ ] Realm naming/language has been updated - [x] All relevant content from individual SDK pages is present on the consolidated page
1 parent 81be17c commit ebc8e9d

File tree

169 files changed

+3964
-52
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

169 files changed

+3964
-52
lines changed
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
part 'schemas.realm.dart';
1+
part 'modelFile.realm.dart';

source/frameworks/flutter/quick-start.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,8 +59,8 @@ classes in your application code with an SDK object schema.
5959
You then have to generate the :flutter-sdk:`RealmObjectBase <realm/RealmObjectBase-mixin.html>`
6060
class that's used within your application.
6161

62-
For more information, refer to :ref:`Define an Object Schema
63-
<sdks-define-object-schema>`.
62+
For more information, refer to :ref:`Define an Object Model
63+
<sdks-define-objects>`.
6464

6565
.. procedure::
6666

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
In C++, when opening a database, you must specify which models are available by
2+
passing the models to the template you use to open the database. Those
3+
models must have schemas, and this list of schemas becomes the database schema.
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
In C++, define an asymmetric object the same way you would
2+
a regular C++ struct or class. Provide a ``REALM_ASYMMETRIC_SCHEMA`` with the
3+
struct or class name as the first argument. Add the names of any properties
4+
that you want the database to persist.
5+
6+
An ``asymmetric_object`` broadly has the same :ref:`supported types
7+
<sdks-define-property-types>` as ``realm::object``, with a few exceptions:
8+
9+
- Asymmetric objects can link to the following types:
10+
- ``object``
11+
- ``embedded_object``
12+
- ``std::vector<embedded_object>``
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
In C++, you define an embedded object by providing a ``REALM_EMBEDDED_SCHEMA``
2+
whose first argument is the struct or class name. Add the names of any
3+
properties that you want the database to persist.
4+
5+
Define a property as an embedded object on the parent object by setting
6+
a pointer to the embedded object's type.
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
The C++ SDK does not currently support geospatial data.
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
In C++, define an optional type using the class template
2+
`std::optional <https://en.cppreference.com/w/cpp/utility/optional>`__.
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
In C++, the base :cpp-sdk:`object <structrealm_1_1internal_1_1bridge_1_1object.html>`
2+
provides accessors and other methods to work with SDK objects, including
3+
things like:
4+
5+
- Checking whether an object is valid
6+
- Getting its managing database instance
7+
- Registering a notification token
8+
9+
Define a C++ struct or class as you would normally. Add a ``REALM_SCHEMA``
10+
whose first value is the name of the struct or class. Add the names of the
11+
properties that you want the database to manage. Omit any fields that you do
12+
not want to persist.
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
In the C++ SDK, you can define your models as regular C++ structs or classes.
2+
Provide an :ref:`sdks-object-schema` with the object type name and
3+
the names of any properties that you want to persist to the database. When you
4+
add the object to the database, the SDK ignores any properties that you omit
5+
from the schema.
6+
7+
You must declare your object and the schema within the ``realm`` namespace.
8+
You must then use the ``realm`` namespace when you initialize and perform CRUD
9+
operations with the object.
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
C++ supports primary keys of the following types, and their optional variants:
2+
3+
- ``int64_t``
4+
- ``realm::object_id``
5+
- ``realm::uuid``
6+
- ``std::string``
7+
8+
Additionally, a required ``realm::enum`` property can be a primary key, but
9+
``realm::enum`` cannot be optional if it is used as a primary key.
10+
11+
Set a property as a primary key with the ``primary_key`` template.

0 commit comments

Comments
 (0)