Skip to content

Commit c573bd1

Browse files
committed
Allow opting out of disk use
1 parent e563d8c commit c573bd1

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

src/cursor/find_cursor.ts

+8-1
Original file line numberDiff line numberDiff line change
@@ -412,8 +412,15 @@ export class FindCursor<TSchema = any> extends AbstractCursor<TSchema> {
412412
* @remarks
413413
* {@link https://docs.mongodb.com/manual/reference/command/find/#find-cmd-allowdiskuse | find command allowDiskUse documentation}
414414
*/
415-
allowDiskUse(): this {
415+
allowDiskUse(allow = true): this {
416416
assertUninitialized(this);
417+
418+
// As of 6.0 the default is true. This allows users to get back to the old behaviour.
419+
if (!allow) {
420+
this[kBuiltOptions].allowDiskUse = false;
421+
return this;
422+
}
423+
417424
if (!this[kBuiltOptions].sort) {
418425
throw new MongoInvalidArgumentError('Option "allowDiskUse" requires a sort specification');
419426
}

0 commit comments

Comments
 (0)