Join us at MongoDB.local London on 7 May to unlock new possibilities for your data. Use WEB50 to save 50%.
Register now >
Docs Menu
Docs Home
/ /
io.realm.mongodb.sync

Clase SyncConfiguration

java.lang.Object
io.realm.mongodb.sync.SyncConfiguration

A SyncConfiguration is used to setup a realm that can be synchronized between devices using MongoDB Realm.

Se requiere un Usuario válido para crear una SyncConfiguration . Consulta Credenciales y App.loginAsync(Credentials, App.función de retorno) para obtener más información sobre cómo obtener un objeto de usuario.

A continuación se encuentra una configuración de sincronización mínima.

App app = new App("app-id");
User user = app.login(Credentials.anonymous());
SyncConfiguration config = SyncConfiguration.defaultConfiguration(user, "partition-value");
Realm realm = Realm.getInstance(config);

Synchronized Realms only support additive migrations which can be detected and performed automatically, so the following builder options are not accessible compared to a normal Realm:

  • deleteRealmIfMigrationNeeded()

  • migration(Migration)

Los reinos sincronizados se crean utilizando Realm.getInstance(RealmConfiguration) y Realm.getDefaultInstance() como los reinos no sincronizados normales.

Tip

  • docs para obtener más información sobre la sincronización.

Modificador y Tipo
Clase y descripción

public static interface

public static final

Modificador y Tipo
Método y descripción

public static SyncConfiguration

User user,
ObjectId partitionValue
)

Returns a default Partition-based Sync configuration for the given user and partition value.

public static SyncConfiguration

User user,
Integer partitionValue
)

Returns a default Partition-based Sync configuration for the given user and partition value.

public static SyncConfiguration

User user,
Long partitionValue
)

Returns a default Partition-based Sync configuration for the given user and partition value.

public static SyncConfiguration

User user,
String partitionValue
)

Returns a default Partition-based Sync configuration for the given user and partition value.

public static SyncConfiguration

Devuelve una configuración Flexible Sync por defecto para el usuario dado.

public booleano

public static RealmConfiguration

String canonicalPath
)

Devuelve una RealmConfiguration apropiada para abrir un Realm de solo lectura, no sincronizado para recuperar cualquier cambio pendiente.

public static RealmConfiguration

String canonicalPath,
byte[] encryptionKey,
)

Devuelve una RealmConfiguration apropiada para abrir un Realm de solo lectura, no sincronizado para recuperar cualquier cambio pendiente.

Returns the Client Reset handler for this SyncConfiguration.

Devuelve el controlador de errores para esta SyncConfiguration.

Returns the transaction instance with initial data.

public long

Returns the timeout defined when downloading any initial data the first time the Realm is opened.

Devuelve el controlador de suscripción inicial configurado para este reino.

public BsonValue

Returns the value this Realm is partitioned on.

public URI

Returns the server URI for the remote MongoDB Realm the local Realm is synchronizing with.

public OsRealmConfig.SyncSessionStopPolicy

NOTA: Solo para uso interno.

Estrategia de restablecimiento decliente de sincronización pública

Devuelve la estrategia de restablecimiento del cliente de sincronización para esta SyncConfiguration.

public String

Devuelve el prefijo de URL utilizado al establecer una conexión de sincronización con el servidor de objetos Realm.

public User

Returns the user.

public int

public booleano

Devuelve si esta configuración es o no para abrir un Reino configurado para sincronización flexible.

public booleano

Devuelve si esta configuración es para abrir un Realm configurado para Partition-based Sync.

protected boolean

protected boolean

Verifica si el archivo Realm definido por esta configuración ya existe.

public booleano

Devuelve true si el archivo Realm debe eliminarse una vez que el usuario propietario cierra la sesión.

public booleano

Devuelve true si Realm descargará todos los cambios conocidos del servidor remoto antes de abrirse por primera vez.

public String

  • Methods inherited from class java.lang.Object : getClass , hashCode , equals , clone , toString , notify , notifyAll , wait , wait , wait , finalize

  • Methods inherited from class io.realm.RealmConfiguration : getRealmDirectory , getRealmFileName , getEncryptionKey , getSchemaVersion , getMigration , shouldDeleteRealmIfMigrationNeeded , getDurability , getSchemaMediator , getInitialDataTransaction , hasAssetFile , getAssetFilePath , getCompactOnLaunchCallback , getRealmObjectClasses , getPath , realmExists , getRxFactory , getFlowFactory , isReadOnly , isRecoveryConfiguration , getMaxNumberOfActiveVersions , isAllowWritesOnUiThread , isAllowQueriesOnUiThread , equals , getInstance , hashCode , createSchemaMediator , toString , isSyncConfiguration , forRecovery

User user,
ObjectId partitionValue
)

Returns a default Partition-based Sync configuration for the given user and partition value.

Parámetros

  • user - The user that will be used for accessing the Realm App.

  • partitionValue - The partition value identifying the remote Realm that will be synchronized.

Devuelve

la configuración predeterminada para el usuario y valor de la partición dados.

User user,
Integer partitionValue
)

Returns a default Partition-based Sync configuration for the given user and partition value.

Parámetros

  • user - The user that will be used for accessing the Realm App.

  • partitionValue - The partition value identifying the remote Realm that will be synchronized.

Devuelve

la configuración predeterminada para el usuario y valor de la partición dados.

User user,
Long partitionValue
)

Returns a default Partition-based Sync configuration for the given user and partition value.

Parámetros

  • user - The user that will be used for accessing the Realm App.

  • partitionValue - The partition value identifying the remote Realm that will be synchronized.

Devuelve

la configuración predeterminada para el usuario y valor de la partición dados.

User user,
String partitionValue
)

Returns a default Partition-based Sync configuration for the given user and partition value.

Parámetros

  • user - The user that will be used for accessing the Realm App.

  • partitionValue - The partition value identifying the remote Realm that will be synchronized.

Devuelve

la configuración predeterminada para el usuario y valor de la partición dados.

User user
)

Devuelve una configuración Flexible Sync por defecto para el usuario dado.

Parámetros

  • user - The user that will be used for accessing the Realm App.

Devuelve

the default Flexible Sync configuration for the given user.

Tip

  • {@link SubscriptionSet} for more information about Flexible Sync.

public boolean equals (
)

Anulaciones

equals en la clase RealmConfiguration

String canonicalPath
)

Returns a RealmConfiguration appropriate to open a read-only, non-synced Realm to recover any pending changes. This is useful when trying to open a backup/recovery Realm (after a client reset). Note: This will use the default Realm module (composed of all RealmModel ), and assume no encryption should be used as well.

Parámetros

  • canonicalPath - the absolute path to the Realm file defined by this configuration.

Devuelve

Configuración de reino que se puede utilizar sin conexión

String canonicalPath,
byte[] encryptionKey,
)

Devuelve una RealmConfiguration adecuada para abrir un dominio de solo lectura no sincronizado y recuperar los cambios pendientes. Esto resulta útil al intentar abrir un dominio de copia de seguridad/recuperación (tras restablecer un cliente).

Parámetros

  • canonicalPath - the absolute path to the Realm file defined by this configuration.

  • encryptionKey - the key used to encrypt/decrypt the Realm file.

  • modules - if specified it will restricts Realm schema to the provided module.

Devuelve

Configuración de reino que se puede utilizar sin conexión

Returns the Client Reset handler for this SyncConfiguration.

Devuelve

the Client Reset handler.

Devuelve el controlador de errores para esta SyncConfiguration.

Devuelve

the error handler.

Returns the transaction instance with initial data.

Devuelve

la transacción de datos inicial.

Anulaciones

getInitialDataTransaction en la clase RealmConfiguration

Returns the timeout defined when downloading any initial data the first time the Realm is opened.This value is only applicable if shouldWaitForInitialRemoteData() returns true .

Devuelve

the time Realm will wait for all changes to be downloaded before it is aborted and an exception is thrown.

Devuelve el controlador de suscripción inicial configurado para este reino.

Devuelve

the handler used to configure initial subscriptions for this realm.

public BsonValue getPartitionValue ()

Devuelve el valor sobre el que está particionado este Realm. La clave de partición es una propiedad definida en MongoDB Realm. Todas las clases con una propiedad con este valor se sincronizarán con el Realm.

Devuelve

the value being used by MongoDB Realm to partition the server side MongoDB Database into Realms that can be synchronized independently.

Throws

public URI getServerUrl ()

Returns the server URI for the remote MongoDB Realm the local Realm is synchronizing with.

Devuelve

URI identifying the MongoDB Realm this local Realm is synchronized with.

public OsRealmConfig.SyncSessionStopPolicy getSessionStopPolicy ()

NOTA: Solo para uso interno. Puede cambiar sin previo aviso. Devuelve la política de detención para la sesión de este Realm una vez que el Realm se ha cerrado.

Devuelve

the stop policy used by the session once the Realm is closed.

Devuelve la estrategia de restablecimiento del cliente de sincronización para esta SyncConfiguration.

Devuelve

the sync client reset strategy.

Devuelve el prefijo de URL utilizado al establecer una conexión de sincronización con el servidor de objetos Realm.

public User getUser ()

Returns the user.

Devuelve

el usuario.

public int hashCode ()

Anulaciones

hashCode en la clase RealmConfiguration

public boolean isFlexibleSyncConfiguration ()

Devuelve si esta configuración es o no para abrir un Reino configurado para sincronización flexible.

Devuelve

true if this configuration is for a Flexible Sync Realm, false if not.

Devuelve si esta configuración es para abrir un Realm configurado para Partition-based Sync.

Devuelve

true if this configuration is for a Partition-based Sync Realm, false if not.

protected boolean isSyncConfiguration ()

Anulaciones

isSyncConfiguration en la clase RealmConfiguration

protected boolean realmExists ()

Checks if the Realm file defined by this configuration already exists.WARNING: This method is just a point-in-time check. Unless protected by external synchronization another thread or process might have created or deleted the Realm file right after this method has returned.

Devuelve

true si el archivo Realm existe, false de lo contrario.

Anulaciones

realmExists en la clase RealmConfiguration

public boolean shouldDeleteRealmOnLogout ()

Devuelve true si el archivo Realm debe eliminarse una vez que el usuario propietario cierra la sesión.

Devuelve

true si el archivo Realm debe ser borrado si el Usuario cierra la sesión. false si se permite que el archivo permanezca.

Devuelve true si Realm descargará todos los cambios conocidos del servidor remoto antes de abrirse por primera vez.

Devuelve

true if all remote changes will be downloaded before the Realm can be opened. false if the Realm can be opened immediately.

public String toString ()

Anulaciones

toString en la clase RealmConfiguration

Volver

SyncClientResetStrategy