Namespace Realms.Sync
Classes
ApiKey
A class representing an API key for a User. It can be used to represent the user when logging in
instead of their regular credentials. These keys are created or fetched through ApiKeys.
An API key's Value is only available when the key is created and cannot be obtained after that.
This means that it's the caller's responsibility to safely store an API key's value upon creation.
App
An App is the main client-side entry point for interacting with a Atlas App Services application.
The App can be used to:
- Register uses and perform various user-related operations through authentication providers (e.g. ApiKeys, EmailPasswordAuth).
- Synchronize data between the local device and a remote Realm App with Synchronized Realms (using SyncConfigurationBase).
- Invoke Realm App functions with Functions (using Functions).
- Access remote data from MongoDB databases with a MongoClient (using GetMongoClient(string)).
To create an app that is linked with a remote Realm App initialize Realm and configure the App as shown below:
var appConfig = new AppConfiguration("my-realm-app-id");
var app = new App(appConfig);
After configuring the App you can start managing users, configure Synchronized Realms, call remote Realm Functions, and access remote data through Mongo Collections.
To register a new user and/or login with an existing user do as shown below:
await app.EmailPassword.RegisterUserAsync("foo@bar.com", "password");
// Login with existing user
var user = app.LoginAsync(Credentials.EmailPassword("foo@bar.com", "password");
With an authorized user you can synchronize data between the local device and the remote Realm App by opening a Realm with a SyncConfigurationBase as indicated below:
var syncConfig = new PartitionSyncConfiguration("some-partition-value", user);
using var realm = await Realm.GetInstanceAsync(syncConfig);
realm.Write(() =>
{
realm.Add(...);
});
await realm.GetSession().WaitForUploadAsync();
You can call remote Realm functions as shown below:
var result = await user.Functions.CallAsync<int>("sum", 1, 2, 3, 4, 5);
And access collections from the remote Realm App as shown here:
var client = user.GetMongoClient("atlas-service");
var db = client.GetDatabase("my-db");
var collection = db.GetCollection("foos");
var foosCount = await collection.CountAsync();
AppConfiguration
A class exposing configuration options for a App.
Credentials
A class, representing the credentials used for authenticating a User.
FlexibleSyncConfiguration
A FlexibleSyncConfiguration is used to setup a Realm whose data can be synchronized between devices using Atlas Device Sync. Unlike PartitionSyncConfiguration, a Realm opened with FlexibleSyncConfiguration will be initially empty until one or more subscriptions are added via Subscriptions.
MongoClient
The remote MongoClient used for working with data in MongoDB remotely via Realm.
MongoClient.Collection<TDocument>
An object representing a remote MongoDB collection.
MongoClient.Database
An object representing a remote MongoDB database.
MongoClient.DeleteResult
The result of DeleteOneAsync(object?) or DeleteManyAsync(object?) operation.
MongoClient.InsertManyResult
The result of InsertManyAsync(IEnumerable<TDocument>) operation.
MongoClient.InsertResult
The result of InsertOneAsync(TDocument) operation.
MongoClient.UpdateResult
The result of UpdateOneAsync(object?, object, bool) or UpdateManyAsync(object?, object, bool) operation.
PartitionSyncConfiguration
A PartitionSyncConfiguration is used to setup a Realm that can be synchronized between devices using Atlas Device Sync.
ReconnectBackoffOptions
Options for configuring the reconnection delay used by the sync client.
Session
An object encapsulating a synchronization session. Sessions represent the communication between the client (and a local Realm file on disk), and MongoDB Atlas. Sessions are always created by the SDK and vended out through various APIs. The lifespans of sessions associated with Realms are managed automatically.
Subscription
A class representing a single query subscription. The server will continuously evaluate the Query that the app subscribed to and will send data that matches it as well as remove data that no longer does.
SubscriptionOptions
A class providing various options to Add<T>(IQueryable<T>, SubscriptionOptions?). All the properties in this class are optional.
SubscriptionSet
A collection representing the set of active subscriptions for a Realm instance. This is used in combination with FlexibleSyncConfiguration to declare the set of queries you want to synchronize with the server. You can access and read the subscription set freely, but mutating it must happen in an Update(Action) block.
SyncConfigurationBase
A SyncConfigurationBase is used to setup a Realm that can be synchronized between devices using Atlas Device Sync. There are two synchronization modes with their respective configurations - "partition" sync with PartitionSyncConfiguration allows you to split your data in separate partitions and synchronize an entire partition with an entire Realm; "flexible" sync with FlexibleSyncConfiguration allows you to start with an empty Realm and send the server a set of queries which it will run and populate the Realm with all documents matching them.
SyncTimeoutOptions
Options for configuring timeouts and intervals used by the sync client.
User
This class represents a user in a Atlas App Services application. The credentials are provided by various 3rd party providers (Facebook, Google, etc.). A user can log in to the server and, if access is granted, it is possible to synchronize the local and the remote Realm. Moreover, synchronization is halted when the user is logged out. It is possible to persist a user. By retrieving a user, there is no need to log in to the 3rd party provider again. Persisting a user between sessions, the user's credentials are stored locally on the device, and should be treated as sensitive data.
User.ApiKeyClient
A class exposing functionality for users to manage API keys from the client. It is always scoped to a particular User and can only be accessed via ApiKeys.
User.FunctionsClient
A class exposing functionality for calling remote Atlas Functions.
UserIdentity
A class containing information about an identity associated with a user.
UserProfile
A class containing profile information about User.
Structs
App.EmailPasswordClient
A class, encapsulating functionality for users, logged in with the EmailPassword provider. It is always scoped to a particular app and can only be accessed via EmailPasswordAuth.
App.SyncClient
A sync manager, handling synchronization of local Realm with MongoDB Atlas. It is always scoped to a particular app and can only be accessed via Sync.
SyncProgress
A struct containing information about the progress state at a given instant.
Enums
ConnectionState
The current connection state of a sync session object.
Credentials.AuthProvider
An enum containing the possible authentication providers. These have to manually be enabled for your app before they can be used.
GoogleCredentialType
The type of the Google credential.
MetadataPersistenceMode
Enumeration that specifies how and if logged-in User objects are persisted across application launches.
ProgressDirection
The transfer direction (upload or download) tracked by a given progress notification subscription.
ProgressMode
The desired behavior of a progress notification subscription.
SessionState
The current state of a sync session object.
SubscriptionSetState
An enum representing the state of a Realm's subscription set.
UserState
The state of the user object.
WaitForSyncMode
An enum controlling when query.SubscribeAsync will wait for synchronization before returning.
Delegates
FlexibleSyncConfiguration.InitialSubscriptionsDelegate
A delegate invoked when a flexible sync Realm is first opened.
SyncConfigurationBase.SessionErrorCallback
Callback triggered when an error occurs in a session.