* Iterates over all the documents for this cursor using the iterator, callback pattern. * * If the iterator returns `false`, iteration will stop. * * @param iterator - The iteration callback. * @deprecated - Will be removed in a future release. Use for await...of instead.
(iterator: (doc: TSchema) => boolean | void)
| 625 | * @deprecated - Will be removed in a future release. Use for await...of instead. |
| 626 | */ |
| 627 | async forEach(iterator: (doc: TSchema) => boolean | void): Promise<void> { |
| 628 | this.signal?.throwIfAborted(); |
| 629 | |
| 630 | if (typeof iterator !== 'function') { |
| 631 | throw new MongoInvalidArgumentError('Argument "iterator" must be a function'); |
| 632 | } |
| 633 | for await (const document of this) { |
| 634 | const result = iterator(document); |
| 635 | if (result === false) { |
| 636 | break; |
| 637 | } |
| 638 | } |
| 639 | } |
| 640 | |
| 641 | /** |
| 642 | * Frees any client-side resources used by the cursor. |
nothing calls this directly
no test coverage detected