Realm.User

Class for managing users.

customData
nullable

Gets this user's associated custom data. This is application-specific data provided by the server.

Type:
object
functions

Convenience wrapper around call_function(name, [args])

Examples::
// These are all equivalent:
await user.call_function("do_thing", [a1, a2, a3]);
await user.functions.do_thing(a1, a2, a3);
await user.functions["do_thing"](a1, a2, a3);
// It it legal to store the functions as first-class values:
const do_thing = user.functions.do_thing;
await do_thing(a1);
await do_thing(a2);
identity

Gets the identity of this user on MongoDB Realm Cloud. The identity is a guaranteed to be unique among all users on MongoDB Realm Cloud .

Type:
string
isLoggedIn

Is true if the user is logged in. False otherwise.

Type:
boolean
profile

Gets the user's profile (name, email address, etc.).

Type:
object
state

Gets the user's state which can be one of the following:

  • LoggedOut - the user is logged out
  • LoggedIn - the user is logged in
  • Removed - the user has been removed
Type:
string
token

Gets this user's refresh token. This is the user's credential for accessing the MongoDB Realm Cloud and should be treated as sensitive data.

Type:
string

Returns a provider to interact with API keys.

Returns: Realm.Auth.APIKeys
  • the provider
callFunction(name, args)

Calls the named server function as this user.

Parameters:
  • name
    • Type: string
    • name of the function to call

  • args
    • Type: [any, ...]
    • list of arguments to pass

linkCredentials(credentials)Promise<Realm.User>

Links a user to another credentials. This is useful when linking different account togteher.

Parameters:
Returns: Promise<Realm.User>
  • updated user object
logOut()

Logs out the user.

refreshCustomData()Promise<Object>

Refresh user's custom data.

See: {Realm.User.customData}
Returns: Promise<Object>