(connection: Connection)
| 56 | } |
| 57 | |
| 58 | override buildCommand(connection: Connection): Document { |
| 59 | if (this.cursorId == null || this.cursorId.isZero()) { |
| 60 | throw new MongoRuntimeError('Unable to iterate cursor with no id'); |
| 61 | } |
| 62 | |
| 63 | const collection = this.ns.collection; |
| 64 | if (collection == null) { |
| 65 | // Cursors should have adopted the namespace returned by MongoDB |
| 66 | // which should always defined a collection name (even a pseudo one, ex. db.aggregate()) |
| 67 | throw new MongoRuntimeError('A collection name must be determined before getMore'); |
| 68 | } |
| 69 | |
| 70 | const getMoreCmd: GetMoreCommand = { |
| 71 | getMore: this.cursorId, |
| 72 | collection |
| 73 | }; |
| 74 | |
| 75 | if (typeof this.options.batchSize === 'number') { |
| 76 | getMoreCmd.batchSize = Math.abs(this.options.batchSize); |
| 77 | } |
| 78 | |
| 79 | if (typeof this.options.maxAwaitTimeMS === 'number') { |
| 80 | getMoreCmd.maxTimeMS = this.options.maxAwaitTimeMS; |
| 81 | } |
| 82 | |
| 83 | // we check for undefined specifically here to allow falsy values |
| 84 | // eslint-disable-next-line no-restricted-syntax |
| 85 | if (this.options.comment !== undefined && maxWireVersion(connection) >= 9) { |
| 86 | getMoreCmd.comment = this.options.comment; |
| 87 | } |
| 88 | |
| 89 | return getMoreCmd; |
| 90 | } |
| 91 | |
| 92 | override buildOptions(timeoutContext: TimeoutContext): ServerCommandOptions { |
| 93 | return { |
no test coverage detected