* Map all documents using the provided function * If there is a transform set on the cursor, that will be called first and the result passed to * this function's transform. * * @remarks * * **Note** Cursors use `null` internally to indicate that there are no more documents in the c
(transform: (doc: TSchema) => T)
| 737 | * @param transform - The mapping transformation method. |
| 738 | */ |
| 739 | map<T = any>(transform: (doc: TSchema) => T): AbstractCursor<T> { |
| 740 | this.throwIfInitialized(); |
| 741 | const oldTransform = this.transform; |
| 742 | if (oldTransform) { |
| 743 | this.transform = doc => { |
| 744 | return transform(oldTransform(doc)); |
| 745 | }; |
| 746 | } else { |
| 747 | this.transform = transform; |
| 748 | } |
| 749 | |
| 750 | return this as unknown as AbstractCursor<T>; |
| 751 | } |
| 752 | |
| 753 | /** |
| 754 | * Set the ReadPreference for the cursor. |
nothing calls this directly
no test coverage detected