Skip to content

Commit 3aafc01

Browse files
committed
docstrings
1 parent 3c1128a commit 3aafc01

File tree

2 files changed

+29
-0
lines changed

2 files changed

+29
-0
lines changed

Sources/MongoSwift/ChangeStream.swift

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -193,6 +193,18 @@ public class ChangeStream<T: Codable>: CursorProtocol {
193193
}
194194
}
195195

196+
/**
197+
* Calls the provided closure with each event in the change stream as it arrives.
198+
*
199+
* - Returns:
200+
* An `EventLoopFuture<Void>` which will succeed once the change stream is killed via `kill`.
201+
*
202+
* If the future evaluates to an error, that error is likely one of the following:
203+
* - `CommandError` if an error occurs while fetching more results from the server.
204+
* - `LogicError` if this function is called after the change stream has died.
205+
* - `LogicError` if this function is called and the session associated with this change stream is inactive.
206+
* - `DecodingError` if an error occurs decoding the server's responses.
207+
*/
196208
public func forEach(_ body: @escaping (T) throws -> Void) -> EventLoopFuture<Void> {
197209
return self.client.operationExecutor.execute {
198210
while let next = try self.processEvent(self.wrappedCursor.next()) {

Sources/MongoSwift/MongoCursor.swift

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -180,6 +180,23 @@ public class MongoCursor<T: Codable>: CursorProtocol {
180180
}
181181
}
182182

183+
/**
184+
* Calls the provided closure with each element in the cursor.
185+
*
186+
* If the cursor is not tailable, this method will exhaust it, calling the closure with every document.
187+
*
188+
* If the cursor is tailable, the method will call the closure with each new document as it arrives.
189+
*
190+
* - Returns:
191+
* An `EventLoopFuture<Void>` which will succeed when the end of the cursor is reached, or in the case of a
192+
* tailable cursor, when the cursor is killed via `kill`.
193+
*
194+
* If the future evaluates to an error, that error is likely one of the following:
195+
* - `CommandError` if an error occurs while fetching more results from the server.
196+
* - `LogicError` if this function is called after the cursor has died.
197+
* - `LogicError` if this function is called and the session associated with this cursor is inactive.
198+
* - `DecodingError` if an error occurs decoding the server's responses.
199+
*/
183200
public func forEach(_ body: @escaping (T) throws -> Void) -> EventLoopFuture<Void> {
184201
return self.client.operationExecutor.execute {
185202
while let next = try self.decode(result: self.wrappedCursor.next()) {

0 commit comments

Comments
 (0)