User

  • Links the currently authenticated user with a new identity, where the identity is defined by the credential specified as a parameter. This will only be successful if this User is the currently authenticated with the client from which it was created. On success a new user will be returned with the new linked credentials. @param credentials The Credentials used to link the user to a new identity. @completion A completion that eventually return Result.success(User) with user’s data or Result.failure(Error).

  • Create a sync configuration instance.

  • The custom data of the user. This is configured in your Atlas App Services app.

  • A client for interacting with a remote MongoDB instance

  • Call an Atlas App Services function with the provided name and arguments.

    user.functions.sum([1, 2, 3, 4, 5]) { sum, error in
        guard case let .int64(value) = sum else {
            print(error?.localizedDescription)
        }
    
        assert(value == 15)
    }
    

    The dynamic member name (sum in the above example) is directly associated with the function name. The first argument is the BSONArray of arguments to be provided to the function. The second and final argument is the completion handler to call when the function call is complete. This handler is executed on a non-main global DispatchQueue.

  • Refresh a user’s custom data. This will, in effect, refresh the user’s auth session. @completion A completion that eventually return Result.success(Dictionary) with user’s data or Result.failure(Error).

  • Create a flexible sync configuration instance, which can be used to open a realm which supports flexible sync.

    It won’t be possible to combine flexible and partition sync in the same app, which means if you open a realm with a flexible sync configuration, you won’t be able to open a realm with a PBS configuration and the other way around.

  • Create a flexible sync configuration instance, which can be used to open a realm which supports flexible sync.

    It won’t be possible to combine flexible and partition sync in the same app, which means if you open a realm with a flexible sync configuration, you won’t be able to open a realm with a PBS configuration and the other way around.

    Using rerunOnOpen covers the cases where you want to re-run dynamic queries, for example time ranges.

    var config = user.flexibleSyncConfiguration(initialSubscriptions: { subscriptions in
        subscriptions.append(QuerySubscription<User>() {
            $0.birthdate < Date() && $0.birthdate > Calendar.current.date(byAdding: .year, value: 21)!
        })
    }, rerunOnOpen: true)