diff --git a/lib/collection.js b/lib/collection.js index dec96cc7e9..a45e4d3b85 100644 --- a/lib/collection.js +++ b/lib/collection.js @@ -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} @@ -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; diff --git a/lib/core/wireprotocol/query.js b/lib/core/wireprotocol/query.js index c501b50644..945550830c 100644 --- a/lib/core/wireprotocol/query.js +++ b/lib/core/wireprotocol/query.js @@ -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;