MCPcopy
hub / github.com/mongodb/node-mongodb-native / map

Function map

src/cursor/abstract_cursor.ts:739–751  ·  view source on GitHub ↗

* 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)

Source from the content-addressed store, hash-verified

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.

Callers

nothing calls this directly

Calls 1

transformFunction · 0.50

Tested by

no test coverage detected