To use Alas Device Sync you must define your data model in two formats:
App Services Schema: A server-side schema which defines your data in BSON. Device Sync uses the App Services Schema to convert your data to MongoDB documents and enforce validation and synchronize data between client devices and Atlas.
Realm Object Schema: Client-side schema of data defined using the Realm SDKs. Each Realm SDK defines the Realm Object Schema in its own language-specific way. The Realm SDKs use this schema to store data in Realm Database and synchronize data with Device Sync.
The App Services Schema and Realm Object Schema must be consistent with each other to sync data using Device Sync.
You can also sync data between clients using different Realm SDKs, as long as they implement the same Realm Object Schema. These Realm Object Schemas must all be consistent with the App Services Schema as well.
For example, you have an iOS app and an Android app with their Realm Object Schemas defined using the Realm Swift SDK and the Realm Kotlin SDK, respectively. Both these mobile applications sync data using the same App Services App with Device Sync. The Swift SDK schema and the Kotlin SDK schema must both be consistent with the same App Services Schema.
You can create your Device Sync data model in a few ways.
If you already have data in Atlas, you can generate an App Services Schema by sampling that data. You can then generate a Realm Object Schema for each Realm SDK.
If you prefer to develop your Realm Object Schema using the Realm SDKs first, use Development Mode. When you use Development Mode, Device Sync automatically generates an App Services Schema when you sync data from a client using a Realm SDK.
For more information on these approaches to modeling data, refer to Create a Data Model.
When developing an application using Atlas Device Sync, you may need to make changes to your data model. This means you also need to update your App Services Schema and Realm Object Schema.
For more information on how to perform the different types of data model changes, refer to Update a Data Model.
To learn more about how the Realm Object Schemas map to the App Services Schemas when using Development Mode, refer to Data Model Mapping.