Cursor

public final class Cursor<T>

A Cursor is a pointer to a sequence/collection of Documents on the MongoDB server.

It can be looped over using a for let document in cursor loop like any other sequence.

It can be transformed into an array with Array(cursor) and allows transformation to another type.

  • Undocumented

    Declaration

    Swift

    public final class Cursor<T>
  • A closure that transforms a document to another type if possible, otherwise nil

    Declaration

    Swift

    typealias Transformer = (Document) throws -> (T?)
  • An efficient and lazy forEach operation specialized for MongoDB.

    Designed to throw errors in the case of a cursor failure, unline normal for .. in cursor operations

    Declaration

    Swift

    public func forEach(_ body: (T) throws -> Void) throws
  • An efficient and lazy flatmap operation specialized for MongoDB

    Declaration

    Swift

    public func flatMap<B>(transform: @escaping (T) throws -> (B?)) throws -> Cursor<B>
  • Makes an iterator to loop over the data this cursor points to from (for example) a loop

    Declaration

    Swift

    public func makeIterator() -> Cursor<T>

    Return Value

    The iterator

  • Fetches the next entity in the Cursor

    Declaration

    Swift

    public func next() -> T?
  • A description for debugging purposes

    Declaration

    Swift

    public var description: String