Make the MongoDB docs better! We value your opinion. Share your feedback for a chance to win $100.
Click here >
Docs Menu
Docs Home
/ /
Java SDK

Sync Data Between Devices - Java SDK

Atlas Device Sync sincroniza automáticamente los datos entre las aplicaciones cliente y un Servicios de aplicaciones Atlas. Cuando un dispositivo cliente está conectado, Sync sincroniza los datos de forma asincrónica en un hilo en segundo plano entre el dispositivo y la aplicación de backend.

Tip

Al seleccionar la Sincronización Flexible para la configuración de la aplicación backend, la implementación del cliente debe incluir suscripciones a consultas en campos consultables. La Sincronización Flexible funciona sincronizando los datos que coinciden con las suscripciones a consultas que mantiene en la aplicación cliente.

Un conjunto de suscripciones contiene un conjunto de queries. Realm Flexible Sync retorna documentos que coinciden con esas queries, cuando el usuario tiene los permisos apropiados para leer y/o leer y guardar los documentos. Si los documentos cumplen la query, pero el cliente no tiene permisos para leerlos o guardar en ellos, no se sincronizan con la aplicación cliente.

You can form queries using Realm Query Language.

Nota

Flexible Sync no admite todos los operadores del query disponibles en el Realm Query Language y el motor de queries de los SDK. Consulta Limitaciones de Flexible Sync RQL para más detalles.

Subscription sets are based on a specific type of Realm object. You might have multiple subscriptions if you have many types of Realm objects.

To use Flexible Sync in your client application, open a synced realm with a flexible sync configuration. Then, manage subscriptions to determine which documents to sync.

The syntax to read, write, and watch for changes on a synced realm is identical to the syntax for non-synced realms. While you work with local data, a background thread efficiently integrates, uploads, and downloads changesets.

Importante

When Using Sync, Avoid Writes on the Main Thread

The fact that Realm performs sync integrations on a background thread means that if you write to your realm on the main thread, there's a small chance your UI could appear to hang as it waits for the background sync thread to finish a write transaction. Therefore, it's a best practice never to write on the main thread when using Sync.

Every write transaction for a subscription set has a performance cost. If you need to make multiple updates to a Realm object during a session, consider keeping edited objects in memory until all changes are complete. This improves sync performance by only writing the complete and updated object to your realm instead of every change.

Volver

Crear y gestionar API keys de usuario

En esta página