Docs Menu
Docs Home
/ /
Atlas Device SDKs
/

View Atlas Data with Device Sync

On this page

  • Prerequisites
  • Connect to Atlas from Realm Studio
  • Select Connect via Atlas Device Sync
  • Provide the requested metadata
  • Connect
  • Specify the Data to Sync
  • Add a Subscription
  • Remove a Subscription
  • View Synced Changes in Real Time

You can use Realm Studio to connect to MongoDB Atlas using Device Sync. Realm Studio functions as a sync client, similar to an application that uses Device Sync. You can:

  • Add and remove subscriptions on the focused object schema.

  • Interact with Atlas data directly from Realm Studio.

Use Realm Studio to see changes to data that you make when running an app in development, or experiment with permissions and subscription changes.

Minimum Realm Studio version: 14.1.2.

Because Device Sync connects Realm Studio to the App Services backend through an Atlas App Services App, you need to following before you can get started:

  1. An Atlas App Services App with authentication enabled. To learn how, refer to Create an App Services App in the App Services documentation.

  2. The App Services App ID. To learn how to find the App ID, refer to Find Your App ID.

Realm Studio can connect via Device Sync using any of these authentication provider types:

  • Anonymous

  • Email & Password

  • API Key

  • JWT

If your App uses Email & Password, API Key, or JWT authentication, you must create a credential of the appropriate type to use when you connect from Realm Studio. For more information about creating credentials, refer to the App Services documentation:

1

Open Realm Studio, and click Connect via Atlas Device Sync.

2
  1. Provide the App ID.

  2. If your App Services App uses a custom URL, specify the URL.

  3. Select the form of authentication your app uses. If you select a form of authentication that requires credentials, provide the credentials.

3

Click Connect.

After you have successfully connected, Realm Studio shows the App ID in the menu bar of the application window. You can open connections to multiple App Services Apps simultaneously. You can also open multiple connections to the same App Services App if you want to view changes in real time.

After you connect to Atlas, Realm Studio displays a list of object types matching the schemas for your App Services App.

For more information about App Services schemas, refer to Schemas in the App Services documentation.

Realm Studio maps these schemas to Realm objects. For information about how these schemas map to Realm objects using Device Sync, refer to Data Model Mapping in the App Services documentation.

You can't see any data for the object types until you add subscriptions for each object type. The subscriptions, plus the permissions that you've defined for your app, determine what data syncs.

To begin viewing data for a specific object type, add a subscription. To change the data you see, you can either:

  • Add more subscriptions to apply additional filtering.

  • Remove a subscription.

You cannot change a subscription that you have added to Realm Studio. To change the subscription, remove it and add a new subscription.

1

If you have schemas for multiple object types in your App Services App, you see them as a list of object type names in the left pane of the Realm Studio window.

Click an object type name to select that object type.

2

When you have selected an object type, a Subscriptions label with a + button displays at the bottom of the left pane of the Realm Studio window.

Click + next to the label to open the Add subscription on Object modal.

3

Use Realm Query Language (RQL) to create a query for the objects you want to sync with Realm Studio. Only the objects that match your query will appear in Realm Studio. You can use this as a way to quickly validate queries when developing your application.

Your subscription query must include at least one queryable field. For more information about queryable fields, refer to Queryable Fields in the App Services documentation.

For information about available query operators, refer to the Realm Query Language (RQL) reference.

Device Sync supports using a subset of RQL operators in Sync subscription queries. For information on these limitations, refer to Device Sync Subscription Queries.

Example

If you bootstrap Device Sync with a Template App, the subscription that the template apps use is:

`owner_id == "${user?.id}"`

To view the applicable data in Realm Studio, use this query with a specific user's ID:

owner_id == "67ee25f483c29fa14cfd7295"

To view all data where the credentials you provided to Realm Studio have the appropriate permissions, use the query:

TRUEPREDICATE
4

Click Add subscription to complete the process of adding a subscription. This triggers an initial sync with Device Sync for:

  • Items of the selected object type.

  • Which match the subscription query you provide.

  • Where the credentials you used to log into Realm Studio have permissions to view the item.

After a moment, you see the number of objects change from 0 to reflect the number of objects that meet this criteria.

5

Your App Services App may have schemas for multiple object types. You must individually add subscriptions for each object type you want to view in Realm Studio.

If your objects include links to other objects, as in to-one or to-many relationships, the linked objects do not appear in Realm Studio until you have added the appropriate subscription on the linked object types.

1

Click an object type name in the left pane of the Realm Studio window to select that object type.

2

Click the to remove a subscription. If you do not see the icon, drag to widen the left pane. Long subscriptions can push the icon out of the viewable area.

The data matching the subscription disappears from Realm Studio after you remove the subscription.

Once you have added a subscription, if your credentials permit it based on your App's rules, you can create, update, and delete objects. When you make changes to objects while connected with Device Sync, those changes automatically sync with Atlas and with other devices. You can see your changes reflected in real time.

For information about how to create, modify, and delete objects in Realm Studio, refer to Modify Objects in a Realm File. You don't need to do anything to save changes that you make while connected with Device Sync. Those changes automatically sync with the server and persist in Atlas.

If you attempt to modify or add an object that does not match your subscriptions or where you do not have write permissions, Device Sync reacts with a compensating write error. Realm Studio reverts those changes, and they do not sync with Atlas or other devices. For more information, refer to ErrorCompensatingWrite in the Flexible Sync Errors section of the App Services Documentation.

← Install Realm Studio