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

Method _initialize

src/cursor/find_cursor.ts:72–98  ·  view source on GitHub ↗

@internal

(session: ClientSession)

Source from the content-addressed store, hash-verified

70
71 /** @internal */
72 async _initialize(session: ClientSession): Promise<InitialCursorResponse> {
73 const options = {
74 ...this.findOptions, // NOTE: order matters here, we may need to refine this
75 ...this.cursorOptions,
76 session,
77 signal: this.signal
78 };
79
80 if (options.explain) {
81 try {
82 validateExplainTimeoutOptions(options, Explain.fromOptions(options));
83 } catch {
84 throw new MongoAPIError(
85 'timeoutMS cannot be used with explain when explain is specified in findOptions'
86 );
87 }
88 }
89
90 const findOperation = new FindOperation(this.namespace, this.cursorFilter, options);
91
92 const response = await executeOperation(this.client, findOperation, this.timeoutContext);
93
94 // the response is not a cursor when `explain` is enabled
95 this.numReturned = response.batchSize;
96
97 return { server: findOperation.server, session, response };
98 }
99
100 /** @internal */
101 override async getMore(): Promise<CursorResponse> {

Callers 1

cursorInitFunction · 0.45

Calls 3

executeOperationFunction · 0.90
fromOptionsMethod · 0.45

Tested by

no test coverage detected