Realm~App

The class represents an Atlas App Services Application.

let app = new Realm.App(config);

Related Classes

Sync
allUsers

Returns a dictionary of alll users. Users' identity is used as key.

currentUser

Returns the current user if any.

emailPasswordAuth

Client for the email/password authentication provider.

Example:
{
// Creating a new user, by registering via email & password
const app = new Realm.App(config);
await app.emailPasswordAuth.registerUser({ email: 'john@example.com', password: 'some-secure-password' });
}
new App(configOrId)

Creates a new app and connects to an Atlas App Services instance.

Parameters:
  • configOrId
    • Type: AppConfiguration or string
    • The configuration of the app or a string app id.

Throws:
  • If no app id is provided.

addListener(callback)

Adds a listener that will be fired on various user events. This includes login, logout, switching users, linking users and refreshing custom data.

Parameters:
  • callback
    • Type: function
deleteUser(user)Promise<void>

Deletes the user. NOTE: This irrecoverably deletes the user from the device as well as the server!

Parameters:
Returns: Promise<void>
getApp(appId)Realm.App

Returns an instance of an app. If an app with the specified id hasn't been created, a new app instance will be created.

Parameters:
  • appId
    • Type: string
Returns: Realm.App
logIn(credentials)Promise<Realm.User>

Logs in a user.

Parameters:
Returns: Promise<Realm.User>
removeListener(callback)

Removes an event listener (see addListener)

Parameters:
  • callback
    • Type: function
removeListener()

Removes all event listeners

removeUser(user)Promise<void>

Removes the user from the client.

Parameters:
Returns: Promise<void>
switchUser(user)

Switches the current user.

Parameters:
Throws:
  • If user is not logged in.

AppConfiguration

This describes the options used to create a Realm.App instance.

Type:
Object
Properties:
  • id
    • Type: string
    • The id of the Atlas App Services application.

  • baseUrl optional
    • Type: string
    • The base URL of the Atlas App Services server.

  • timeout optional
    • Type: number
    • General timeout (in millisecs) for requests.

  • baseFilePath optional
    • Type: string
    • Specify where synced Realms and metadata is stored. If not specified, the current work directory is used.

LocalAppConfiguration

This describes the options used for local app configuration.

Type:
Object
Properties:
  • name
    • Type: string
    • The name of the app.

  • version
    • Type: string
    • The version of the app.