Instance Methodmongokitten 7.9.5MongoKitten
forEach(failable:handler:)
Executes the given handler
for every element of the cursor.
@discardableResult func forEach(failable: Bool = false, handler: @escaping (Element) async throws -> Void) -> Task<Void, Error>
Parameters
- handler
A handler to execute on every result
Returns
A future that resolves when the operation is complete, or fails if an error is thrown
Other members in extension
Instance members
func drain(failable: Bool
) async throws -> [Element] Executes the cursor and returns all results as an array Please be aware that this may consume a large amount of memory or time with a large number of results
func firstResult(
) async throws -> Element? Executes the cursor and returns the first result Always uses a batch size of 1
func map<E>(transform: @escaping (Element) async throws -> E
) -> MappedCursor<Self, E> Returns a new cursor with the results of mapping the given closure over the cursor’s elements. This operation is lazy.