diff --git a/lib/MTWrapper.js b/lib/MTWrapper.js index 5b726fd..46fc53b 100644 --- a/lib/MTWrapper.js +++ b/lib/MTWrapper.js @@ -49,11 +49,13 @@ class MTWrapper { command += ' --nsInclude ' + options.db + '.*'; } } - if (isRestore && !isLegacyRestoreDb() - && isOptionSet(options, 'dbFrom') - && isOptionSet(options, 'dbTo') - && !isOptionSet(options, 'db')) { - command += ' --nsFrom ' + options.dbFrom + '.*' + ' --nsTo ' + options.dbTo + '.*' + if (isRestore && + !isLegacyRestoreDb() && + isOptionSet(options, 'dbFrom') && + isOptionSet(options, 'dbTo') && + !isOptionSet(options, 'db')) { + command += ' --nsFrom ' + options.dbFrom + '.*' + ' --nsTo ' + options.dbTo + '.*'; + command += ' --nsInclude ' + options.dbFrom + '.*'; } if (isBooleanOptionSet(options, 'ssl')) { command += ' --ssl'; diff --git a/tests/mongo-wrapper-unit.test.js b/tests/mongo-wrapper-unit.test.js index a87207b..6aa7281 100644 --- a/tests/mongo-wrapper-unit.test.js +++ b/tests/mongo-wrapper-unit.test.js @@ -81,7 +81,10 @@ describe("🧪🧩 MTWrapper unit tests", function () { const command = wrapper.commandConnectFromOptions(mtOptions, '--beginning', true); - command.should.be.eql("--beginning --host 127.0.0.1 --port 17017 --username myUser --password myPass --authenticationDatabase admin --nsFrom mySourceDbForTest.* --nsTo myTargetDbForTest.*"); + command.should.be.eql("--beginning --host 127.0.0.1 --port 17017 --username myUser --password myPass " + + "--authenticationDatabase admin " + + "--nsFrom mySourceDbForTest.* --nsTo myTargetDbForTest.* " + + "--nsInclude mySourceDbForTest.*"); }); it("🧪 should wrap restore commandConnectFromOptions uri ssl", async function () {