Skip to content

Commit

Permalink
feat: support allowDiskUse for find commands
Browse files Browse the repository at this point in the history
  • Loading branch information
mbroadst committed Feb 11, 2020
1 parent faee15b commit dbc0b37
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
5 changes: 5 additions & 0 deletions lib/collection.js
Original file line number Diff line number Diff line change
Expand Up @@ -313,6 +313,7 @@ const DEPRECATED_FIND_OPTIONS = ['maxScan', 'fields', 'snapshot'];
* @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
* @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.
* @param {object} [options.collation] Specify collation (MongoDB 3.4 or higher) settings for update operation (see 3.4 documentation for available fields).
* @param {boolean} [options.allowDiskUse] Enables writing to temporary files on the server.
* @param {ClientSession} [options.session] optional session to use for this operation
* @throws {MongoError}
* @return {Cursor}
Expand Down Expand Up @@ -422,6 +423,10 @@ Collection.prototype.find = deprecateOptions(
query: selector
};

if (typeof options.allowDiskUse === 'boolean') {
findCommand.allowDiskUse = options.allowDiskUse;
}

// Ensure we use the right await data option
if (typeof newOptions.awaitdata === 'boolean') {
newOptions.awaitData = newOptions.awaitdata;
Expand Down
4 changes: 4 additions & 0 deletions lib/core/wireprotocol/query.js
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,10 @@ function prepareFindCommand(server, ns, cmd, cursorState) {
sortValue = sortObject;
}

if (typeof cmd.allowDiskUse === 'boolean') {
findCmd.allowDiskUse = cmd.allowDiskUse;
}

if (cmd.sort) findCmd.sort = sortValue;
if (cmd.fields) findCmd.projection = cmd.fields;
if (cmd.hint) findCmd.hint = cmd.hint;
Expand Down

0 comments on commit dbc0b37

Please sign in to comment.