Link a MongoDB Data Source¶
Overview¶
You can use MongoDB Realm to work with a data source -- either a MongoDB Atlas cluster or Data Lake associated with the same Atlas project as your Realm app. To connect to a data source through Realm, you must first link it to a new MongoDB service in your application.
You can create a MongoDB service and link a data source to your Realm app through the Realm UI or with an import/export configuration directory. Select the tab below that corresponds to the method you want to use.
In order to use Realm Sync, your Atlas cluster must use MongoDB version 4.4.
Procedure¶
Navigate to the Data Source Management Screen¶
In the Realm UI, click Linked Data Sources under Manage in the left navigation menu.
Link a New Data Source¶
Click Link a Data Source and provide the following configuration information on the Data Source Configuration screen:
Field | Description | |
---|---|---|
Data Source | A MongoDB Atlas cluster or Data Lake associated with the same project as your Realm app. | |
Realm Service Name | A name for the Realm service that connects to the data source. You will use this name when referring to the data source in other parts of your application, such as when you instantiate a MongoDB service client. Example Consider a MongoDB cluster data source with the Realm
Service Name
| |
MongoDB Connection String config.wireProtocolEnabled | Required for Atlas clusters. Not enabled for Data Lakes. A boolean indicating whether Realm should allow clients to connect to this cluster with a connection string over the wire protocol. | |
Read Preference | Required for Atlas clusters. Not available for Data Lakes. Specifies the read preference of the cluster. The default read preference (primary) should be sufficient for most use cases. |
Save the Linked Data Source¶
Once you've selected and configured a MongoDB cluster or Data Lake, click Save.
Realm will immediately begin the process of linking to the data source, which could take up to five minutes. Once Realm is finished linking to the data source, you can start working with the data.
Linked Data Lake Considerations¶
For the most part, you can interact with a linked Data Lake just as you would with a linked Atlas cluster. However, there are some caveats to keep in mind when working with a Data Lake:
- Data Lakes do not support write operations.
- You can only access a linked Data Lake from a system function.
- You cannot connect to the Data Lake via the wire protocol.
- You cannot define roles and permissions for a linked Data Lake.
- You cannot set a Read Preference for a linked Data Lake.
Work with a Linked Data Source¶
The following pages demonstrate how to start working with your linked data source from a function:
You can access your MongoDB data source remotely from a client. See the following sections of the Client Guides:
- MongoDB Data Access (Android SDK)
- Remotely Access MongoDB (iOS SDK)
- MongoDB Data Access (Node SDK)
- MongoDB Data Access (React Native SDK)