MongoCursor
public class MongoCursor<T> : Sequence, IteratorProtocol where T : Decodable, T : Encodable
A MongoDB cursor.
-
Cleans up internal state.
Declaration
Swift
deinit
-
Closes the cursor.
Declaration
Swift
public func close()
-
Returns the next
Document
in this cursor ornil
, or throws an error if one occurs – compared tonext()
, which returnsnil
and requires manually checking for an error afterward.Throws
ServerError.commandError
if an error occurs on the server while iterating the cursor.UserError.logicError
if this function is called after the cursor has died.DecodingError
if an error occurs decoding the server’s response.
Declaration
Swift
public func nextOrError() throws -> T?
Return Value
the next
Document
in this cursor, ornil
if at the end of the cursor -
The error that occurred while iterating this cursor, if one exists. This should be used to check for errors after
next()
returnsnil
.Declaration
Swift
public var error: Error? { get }