Class User<UserFunctionsFactoryType, UserCustomDataType, UserProfileDataType>

Representation of an authenticated user of an App.

Type Parameters

Accessors

  • get customData(): UserCustomDataType
  • You can store arbitrary data about your application users in a MongoDB collection and configure Atlas App Services to automatically expose each user’s data in a field of their user object. For example, you might store a user’s preferred language, date of birth, or their local timezone.

    If this value has not been configured, it will be empty.

    Returns UserCustomDataType

    The custom data as an object.

Methods

  • Adds a listener that will be fired on various user related events. This includes auth token refresh, refresh token refresh, refresh custom user data, and logout.

    Parameters

    Returns void

  • Call a remote Atlas App Services Function by its name.

    Parameters

    • name: string

      Name of the App Services Function.

    • Rest ...args: unknown[]

      Arguments passed to the Function.

    Returns Promise<unknown>

    A promise that resolves to the value returned by the Function.

    Note

    Consider using functions[name]() instead of calling this method.

    Example

    // These are all equivalent:
    await user.callFunction("doThing", a1, a2, a3);
    await user.functions.doThing(a1, a2, a3);
    await user.functions["doThing"](a1, a2, a3);

    Example

    // The methods returned from the functions object are bound, which is why it's okay to store the function in a variable before calling it:
    const doThing = user.functions.doThing;
    await doThing(a1);
    await doThing(a2);
  • Link the user with an identity represented by another set of credentials.

    Parameters

    • credentials: Credentials

      The credentials to use when linking.

    Returns Promise<void>

    A promise that resolves once the user has been linked with the credentials.

  • Parameters

    • serviceName: string

      The name of the MongoDB service to connect to.

    Returns MongoDB

    A client enabling access to a MongoDB service.

    Example

    let blueWidgets = user.mongoClient("myService")
    .db("myDb")
    .collection<Widget>("widgets")
    .find({ color: "blue" });

Generated using TypeDoc