On this page
If you have a mobile or client application that produces a large volume of data you'd like to stream to MongoDB Atlas, you can sync data unidirectionally using Device Sync. We call the feature that enables this unidirectional sync Data Ingest.
You might want to sync data unidirectionally in IoT applications, such as a weather sensor sending data to the cloud. Data Ingest is also useful for writing other types of immutable data where you do not require conflict resolution, such as creating invoices from a retail app or logging application events.
Data Ingest is optimized to provide performance improvements for heavy client-side insert-only workloads. You cannot read this data from the realm where you're streaming it.
Currently Data Ingest is only available for the following Realm SDKs:
React Native SDK
Follow these high-level steps to get started:
The App Services application is the gateway that enables your client device to connect to MongoDB Atlas. When you create an App, you name it, link it to an Atlas cluster, and specify the deployment model and deployment region that work best for your application.
To learn how to create an App Services App, see Create an App.
Device Sync is the service that synchronizes data to Atlas and across your client devices. Device Sync, together with the Realm SDKs, automatically manages network connectivity, user permissions, and conflict resolution. The App Services app provides the built-in user authentication that Device Sync and the Realm SDKs leverage to secure your data.
When you configure Device Sync, you specify the data source that the client devices can access as well as the permissions that determine what data a user can write.
You can configure Device Sync via the Atlas UI, the Atlas App Services Command Line Interface, or the App Services Admin API. The first time you configure Device Sync, you may find it helpful to use the Atlas UI as it provides links and information about various settings and options.
To enable Data Ingest for one or more collections, you select the collection or collections in the Advanced Configuration section of your Device Sync configuration. Only collections with an App Services Schema are available to select in this drop-down.
If you have not yet created a schema for the collection that you want to sync unidirectionally, you can either:
Generate an App Services schema from your Realm object model. Refer to: Create an App Services Schema from a Realm Object Model.
Manually create an App Services Schema. For more information, refer to: Enforce a Schema.
Your client devices must authenticate in order to access synced data. App Services provides several authentication providers, such as email/password or anonymous authentication, to enable your users to authenticate. Configure one or more of these authentication providers to enable authentication in your client application.
You can configure authentication providers within the App Services App UI by selecting Authentication in the left navigation menu, and then click a provider to configure it. You can also configure authentication providers by editing the App Services configuration with the Atlas App Services Command Line Interface, or the App Services Admin API.
After this, you've got everything set up that you need on the Atlas side, and you can prepare your client application to sync data unidirectionally.
In your client application code, initialize an App client to connect your client to your App Services backend. This lets your client use App Services features like authentication, and enables opening a synced realm.
Your client application user must be authenticated with the App Services backend in order to write synchronized data. Add logic to your client app to register and log in users.
Once you have an authenticated user, you can open a synced instance of Realm Database to use for that user. Because Asymmetric Sync is write-only, you cannot define a Flexible Sync query to read data on the device. This differs from bidirectional Flexible Sync, where you would create a query subscription to determine what data to sync to the device.
The Realm SDKs provide a special type of object to use with Data Ingest: an Asymmetric Object. Refer to the Realm SDK documentation for details on how to define Asymmetric Objects.
Create and write Asymmetric Objects to a synced realm, and the Realm SDKs use Device Sync manage the process of streaming the data automatically. When the device has a network connection, the SDKs stream data to the App Services backend and into Atlas. When the device does not have a network connection, the data persists on the device and automatically uploads when the network connection is restored.
Atlas Device Sync completely manages the lifecycle of this data. It is maintained on the device until Data Ingest synchronization is complete, and then removed from the device.