Functions
@dynamicMemberLookup
@frozen
public struct Functions
Structure providing an interface to call a MongoDB Realm 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
.
-
A closure type for receiving the completion of a remote function call.
Declaration
Swift
public typealias FunctionCompletionHandler = (AnyBSON?, Error?) -> Void
-
A closure type for the dynamic remote function type.
Declaration
Swift
public typealias Function = ([AnyBSON], @escaping FunctionCompletionHandler) -> Void
-
The implementation of @dynamicMemberLookup that allows for dynamic remote function calls.
Declaration
Swift
public subscript(dynamicMember string: String) -> Function { get }
-
A closure type for receiving the completion result of a remote function call.
Declaration
Swift
public typealias ResultFunctionCompletionHandler = (Result<AnyBSON, Error>) -> Void
-
A closure type for the dynamic remote function type.
Declaration
Swift
public typealias ResultFunction = ([AnyBSON], @escaping ResultFunctionCompletionHandler) -> Void
-
The implementation of @dynamicMemberLookup that allows for dynamic remote function calls.
Declaration
Swift
public subscript(dynamicMember string: String) -> ResultFunction { get }
-
The implementation of @dynamicMemberLookup that allows for dynamic remote function calls.
Declaration