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

Function rewind

src/cursor/abstract_cursor.ts:825–851  ·  view source on GitHub ↗

* Rewind this cursor to its uninitialized state. Any options that are present on the cursor will * remain in effect. Iterating this cursor will cause new queries to be sent to the server, even * if the resultant data has already been retrieved by this cursor.

()

Source from the content-addressed store, hash-verified

823 * if the resultant data has already been retrieved by this cursor.
824 */
825 rewind(): void {
826 if (this.timeoutContext && this.timeoutContext.owner !== this) {
827 throw new MongoAPIError(`Cannot rewind cursor that does not own its timeout context.`);
828 }
829 if (!this.initialized) {
830 return;
831 }
832
833 this.cursorId = null;
834 this.documents?.clear();
835 this.timeoutContext?.clear();
836 this.timeoutContext = undefined;
837 this.isClosed = false;
838 this.isKilled = false;
839 this.initialized = false;
840 this.hasEmittedClose = false;
841 this.trackCursor();
842
843 // We only want to end this session if we created it, and it hasn't ended yet
844 if (this.cursorSession?.explicit === false) {
845 if (!this.cursorSession.hasEnded) {
846 this.cursorSession.endSession().then(undefined, squashError);
847 }
848
849 this.cursorSession = null;
850 }
851 }
852
853 /**
854 * Returns a new uninitialized copy of this cursor, with options matching those that have been set on the current instance

Callers

nothing calls this directly

Calls 2

endSessionMethod · 0.80
clearMethod · 0.45

Tested by

no test coverage detected