@internal
(session: ClientSession)
| 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> { |
no test coverage detected