Skip to content

Commit

Permalink
Do not force to pass the databaseName
Browse files Browse the repository at this point in the history
See: #46
  • Loading branch information
seppevs committed Jul 21, 2020
1 parent 0f39678 commit 84494dd
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 20 deletions.
5 changes: 5 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,11 @@ module.exports = {
};
````

Alternatively, you can also encode your database name in the url (and leave out the `databaseName` property):
````
url: "mongodb://localhost:27017/YOURDATABASE",
````

### Creating a new migration script
To create a new database migration script, just run the ````migrate-mongo create [description]```` command.

Expand Down
7 changes: 0 additions & 7 deletions lib/env/database.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,6 @@ module.exports = {
throw new Error("No `url` defined in config file!");
}

if (!databaseName) {
throw new Error(
"No `databaseName` defined in config file! This is required since migrate-mongo v3. " +
"See https://github.com/seppevs/migrate-mongo#initialize-a-new-project"
);
}

const client = await MongoClient.connect(
url,
options
Expand Down
13 changes: 0 additions & 13 deletions test/env/database.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -86,19 +86,6 @@ describe("database", () => {
}
});

it("should yield an error when no databaseName is defined in the config file", async () => {
delete configObj.mongodb.databaseName;
try {
await database.connect();
expect.fail("Error was not thrown");
} catch (err) {
expect(err.message).to.equal(
"No `databaseName` defined in config file! This is required since migrate-mongo v3. " +
"See https://github.com/seppevs/migrate-mongo#initialize-a-new-project"
);
}
});

it("should yield an error when unable to connect", async () => {
mongodb.MongoClient.connect.returns(
Promise.reject(new Error("Unable to connect"))
Expand Down

0 comments on commit 84494dd

Please sign in to comment.