RemoteMongoReadOperation

public class RemoteMongoReadOperation<T> where T : Decodable, T : Encodable

RemoteMongoReadOperation represents a find or aggregate operation on a RemoteMongoCollection.

The methods in this class execute the operation and retrieve the results.

  • Executes the operation and returns the first document in the result.

    Declaration

    Swift

    public func first(_ completionHandler: @escaping (StitchResult<T?>) -> Void)

    Parameters

    completionHandler

    The completion handler to call when the operation is completed or if the operation fails. This handler is executed on a non-main global DispatchQueue. If the operation is successful, the result will contain an optional T indicating the first document in the result. the document will be nil if the result was empty.

  • Executes the operation and returns the result as an array.

    Declaration

    Swift

    public func toArray(_ completionHandler: @escaping (StitchResult<[T]>) -> Void)

    Parameters

    completionHandler

    The completion handler to call when the operation is completed or if the operation fails. This handler is executed on a non-main global DispatchQueue. If the operation is successful, the result will contain the documents in the result as an array.

  • Executes the operation and returns the result as an array. Deprecated in favor of toArray(completionHandler:).

    Declaration

    Swift

    @available(*, deprecated, message: "use toArray instead")
    public func asArray(_ completionHandler: @escaping (StitchResult<[T]>) -> Void)

    Parameters

    completionHandler

    The completion handler to call when the operation is completed or if the operation fails. This handler is executed on a non-main global DispatchQueue. If the operation is successful, the result will contain the documents in the result as an array.

  • Executes the operation and returns a RemoteMongoCursor to its resulting documents.

    Declaration

    Swift

    public func iterator(_ completionHandler: @escaping (StitchResult<RemoteMongoCursor<T>>) -> Void)

    Parameters

    completionHandler

    The completion handler to call when the operation is completed or if the operation fails. This handler is executed on a non-main global DispatchQueue. If the operation is successful, the result will contain an asynchronously iterating cursor to the documents in the result.