diff options
| author | Lucas de Castro Borges <lucas@gnuabordo.com.br> | 2025-02-18 17:02:53 -0300 |
|---|---|---|
| committer | Lucas de Castro Borges <lucas@gnuabordo.com.br> | 2025-02-18 17:02:53 -0300 |
| commit | 959575a5ca598bf5f37fb5cebe7ed1d80d3d71f7 (patch) | |
| tree | acc8d60aedb12b70048e676e8a7349deb0010db8 /src/mongo/shell/query.js | |
| parent | 76588293975fc059cf076779e4283e6ffaf8afff (diff) | |
New upstream version 6.0.20upstream
Diffstat (limited to 'src/mongo/shell/query.js')
| -rw-r--r-- | src/mongo/shell/query.js | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/src/mongo/shell/query.js b/src/mongo/shell/query.js index a5d920cb109..b43e13c23e8 100644 --- a/src/mongo/shell/query.js +++ b/src/mongo/shell/query.js @@ -98,6 +98,10 @@ DBQuery.prototype._canUseCommandCursor = function() { (this._options & DBQuery.Option.exhaust) === 0; }; +DBQuery.prototype._isTailableCursor = function() { + return (this._options & DBQuery.Option.tailable) !== 0; +}; + /** * This method is exposed only for the purpose of testing and should not be used in most contexts. * @@ -301,7 +305,9 @@ DBQuery.prototype.skip = function(skip) { DBQuery.prototype.hasNext = function() { this._exec(); - if (this._limit > 0 && this._cursorSeen >= this._limit) { + // Return when limit is reached for tailable cursors. For other cursor options, like an exhaust + // cursor, the server manages closing. + if (this._isTailableCursor() && this._limit > 0 && this._cursorSeen >= this._limit) { this._cursor.close(); return false; } |
