From a7366056f01d8e8c5773a152918ca4ac4d89588c Mon Sep 17 00:00:00 2001 From: Leonardo Rossi Date: Tue, 1 Mar 2022 06:45:29 +0100 Subject: [PATCH 1/2] Support boolean "true" with currentOp --- packages/shell-api/src/database.spec.ts | 11 +++++++++++ packages/shell-api/src/database.ts | 5 ++++- 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/packages/shell-api/src/database.spec.ts b/packages/shell-api/src/database.spec.ts index 2a37fe9833..7033c427ad 100644 --- a/packages/shell-api/src/database.spec.ts +++ b/packages/shell-api/src/database.spec.ts @@ -1555,6 +1555,17 @@ describe('Database', () => { { currentOp: 1 } ); }); + it('allows boolean parameter', async() => { + await database.currentOp(true); + + expect(serviceProvider.runCommandWithCheck).to.have.been.calledWith( + ADMIN_DB, + { + currentOp: 1, + $all: true + } + ); + }); it('calls serviceProvider.runCommandWithCheck on the database with options', async() => { await database.currentOp({ $ownOps: true, diff --git a/packages/shell-api/src/database.ts b/packages/shell-api/src/database.ts index ca8afd9503..0a4214258f 100644 --- a/packages/shell-api/src/database.ts +++ b/packages/shell-api/src/database.ts @@ -787,8 +787,11 @@ export default class Database extends ShellApiWithMongoClass { @returnsPromise @apiVersions([]) - async currentOp(opts: Document = {}): Promise { + async currentOp(opts: Document | boolean = {}): Promise { this._emitDatabaseApiCall('currentOp', { opts: opts }); + if (opts === true) { + opts = { $all: true }; + } return await this._runAdminCommand( { currentOp: 1, From 13df548b13987a14d4a6af01ed698f59dffb9adb Mon Sep 17 00:00:00 2001 From: Leonardo Rossi Date: Tue, 1 Mar 2022 14:30:23 +0100 Subject: [PATCH 2/2] adds support for falsy parameter --- packages/shell-api/src/database.spec.ts | 11 +++++++++++ packages/shell-api/src/database.ts | 4 ++-- 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/packages/shell-api/src/database.spec.ts b/packages/shell-api/src/database.spec.ts index 7033c427ad..fd53b9f2a1 100644 --- a/packages/shell-api/src/database.spec.ts +++ b/packages/shell-api/src/database.spec.ts @@ -1566,6 +1566,17 @@ describe('Database', () => { } ); }); + it('allows boolean parameter false', async() => { + await database.currentOp(false); + + expect(serviceProvider.runCommandWithCheck).to.have.been.calledWith( + ADMIN_DB, + { + $all: false, + currentOp: 1 + } + ); + }); it('calls serviceProvider.runCommandWithCheck on the database with options', async() => { await database.currentOp({ $ownOps: true, diff --git a/packages/shell-api/src/database.ts b/packages/shell-api/src/database.ts index 0a4214258f..f99c1a056e 100644 --- a/packages/shell-api/src/database.ts +++ b/packages/shell-api/src/database.ts @@ -789,8 +789,8 @@ export default class Database extends ShellApiWithMongoClass { @apiVersions([]) async currentOp(opts: Document | boolean = {}): Promise { this._emitDatabaseApiCall('currentOp', { opts: opts }); - if (opts === true) { - opts = { $all: true }; + if (typeof opts === 'boolean') { + opts = { $all: opts }; } return await this._runAdminCommand( {