UNPKG

realm

Version:

Realm by MongoDB is an offline-first mobile database: an alternative to SQLite and key-value stores

106 lines 5.14 kB
import { App, LogLevel, Logger, OpenRealmBehaviorConfiguration, PartitionValue, SyncSession, User } from "../internal"; import * as internal from "../internal"; export declare class Sync { /** @deprecated Will be removed in v13.0.0. Please use {@link Realm.setLogLevel}. */ static setLogLevel(app: App, level: LogLevel): void; /** @deprecated Will be removed in v13.0.0. Please use {@link Realm.setLogger}. */ static setLogger(app: App, logger: Logger): void; /** * Get all sync sessions for a particular user. * @since 10.0.0 */ static getAllSyncSessions(user: User): SyncSession[]; /** * Get the session associated with a particular user and partition value. * @since 10.0.0 */ static getSyncSession(user: User, partitionValue: PartitionValue): SyncSession | null; /** * Set the application part of the User-Agent string that will be sent to the Realm Object Server when a session * is created. * * This method can only be called up to the point where the first Realm is opened. After that, the User-Agent * can no longer be changed. */ static setUserAgent(app: App, userAgent: string): void; /** * Enable multiplexing multiple sync sessions over a single connection for a Realm app. * When having a lot of synchronized realms open the system might run out of file * descriptors because of all the open sockets to the server. Session multiplexing * is designed to alleviate that, but it might not work with a server configured with * fail-over. Only use if you're seeing errors about reaching the file descriptor limit * and you know you are using many sync sessions. */ static enableSessionMultiplexing(app: App): void; /** * Initiate a client reset. The Realm must be closed prior to the reset. * * A synced Realm may need to be reset if the communications with the Atlas Device Sync Server * indicate an unrecoverable error that prevents continuing with normal synchronization. The * most common reason for this is if a client has been disconnected for too long. * * The local copy of the Realm is moved into a recovery directory * for safekeeping. * * Local writes that were not successfully synchronized to Atlas * will be present in the local recovery copy of the Realm file. The re-downloaded Realm will * initially contain only the data present at the time the Realm was synchronized up on the server. * @deprecated * @throws An {@link Error} if reset is not possible. * @example * { * // Once you have opened your Realm, you will have to keep a reference to it. * // In the error handler, this reference is called `realm` * const config = { * // schema, etc. * sync: { * user, * partitionValue, * error: (session, error) => { * if (error.name === 'ClientReset') { * let path = realm.path; // realm.path will no be accessible after realm.close() * realm.close(); * Realm.App.Sync.initiateClientReset(app, path); * // - open Realm at `error.config.path` (oldRealm) * // - open Realm with `config` (newRealm) * // - copy required objects from oldRealm to newRealm * // - close both Realms * } * } * } * }; * } */ static initiateClientReset(app: App, path: string): void; /** * @deprecated */ static reconnect(app: App): void; /** * The default behavior settings if you want to open a synchronized Realm immediately and start working on it. * If this is the first time you open the Realm, it will be empty while the server data is being downloaded in the background. * @deprecated since v12 */ static openLocalRealmBehavior: Readonly<OpenRealmBehaviorConfiguration>; /** * The default behavior settings if you want to wait for downloading a synchronized Realm to complete before opening it. * @deprecated since v12 */ static downloadBeforeOpenBehavior: Readonly<OpenRealmBehaviorConfiguration>; } export declare namespace Sync { export import ConnectionState = internal.ConnectionState; export import BaseSubscriptionSet = internal.BaseSubscriptionSet; export import LogLevel = internal.LogLevel; export import NumericLogLevel = internal.NumericLogLevel; export import MutableSubscriptionSet = internal.MutableSubscriptionSet; export import PartitionValue = internal.PartitionValue; export import SubscriptionOptions = internal.SubscriptionOptions; export import SubscriptionSet = internal.SubscriptionSet; export import SubscriptionSetState = internal.SubscriptionSetState; /** @deprecated Please use {@link internal.SubscriptionSetState} */ export import SubscriptionsState = internal.SubscriptionSetState; export import Subscription = internal.Subscription; export import Session = internal.SyncSession; } //# sourceMappingURL=Sync.d.ts.map