Skip to content

Commit dbc0b37

Browse files
committed
feat: support allowDiskUse for find commands
NODE-2289
1 parent faee15b commit dbc0b37

File tree

2 files changed

+9
-0
lines changed

2 files changed

+9
-0
lines changed

lib/collection.js

+5
Original file line numberDiff line numberDiff line change
@@ -313,6 +313,7 @@ const DEPRECATED_FIND_OPTIONS = ['maxScan', 'fields', 'snapshot'];
313313
* @param {number} [options.maxAwaitTimeMS] The maximum amount of time for the server to wait on new documents to satisfy a tailable cursor query. Requires `taiable` and `awaitData` to be true
314314
* @param {boolean} [options.noCursorTimeout] The server normally times out idle cursors after an inactivity period (10 minutes) to prevent excess memory use. Set this option to prevent that.
315315
* @param {object} [options.collation] Specify collation (MongoDB 3.4 or higher) settings for update operation (see 3.4 documentation for available fields).
316+
* @param {boolean} [options.allowDiskUse] Enables writing to temporary files on the server.
316317
* @param {ClientSession} [options.session] optional session to use for this operation
317318
* @throws {MongoError}
318319
* @return {Cursor}
@@ -422,6 +423,10 @@ Collection.prototype.find = deprecateOptions(
422423
query: selector
423424
};
424425

426+
if (typeof options.allowDiskUse === 'boolean') {
427+
findCommand.allowDiskUse = options.allowDiskUse;
428+
}
429+
425430
// Ensure we use the right await data option
426431
if (typeof newOptions.awaitdata === 'boolean') {
427432
newOptions.awaitData = newOptions.awaitdata;

lib/core/wireprotocol/query.js

+4
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,10 @@ function prepareFindCommand(server, ns, cmd, cursorState) {
100100
sortValue = sortObject;
101101
}
102102

103+
if (typeof cmd.allowDiskUse === 'boolean') {
104+
findCmd.allowDiskUse = cmd.allowDiskUse;
105+
}
106+
103107
if (cmd.sort) findCmd.sort = sortValue;
104108
if (cmd.fields) findCmd.projection = cmd.fields;
105109
if (cmd.hint) findCmd.hint = cmd.hint;

0 commit comments

Comments
 (0)