Skip to content

Commit f1ddf2a

Browse files
committed
docs: use process.env.MONGO_URL, get rid of global.__MONGO_DB_NAME__ in example
1 parent 61244ce commit f1ddf2a

File tree

3 files changed

+17
-6
lines changed

3 files changed

+17
-6
lines changed

mongo-aggregate.test.js

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,11 @@ describe('insert', () => {
55
let db;
66

77
beforeAll(async () => {
8-
connection = await MongoClient.connect(global.__MONGO_URI__, {useNewUrlParser: true});
9-
db = await connection.db(global.__MONGO_DB_NAME__);
8+
connection = await MongoClient.connect(process.env.MONGO_URL, {
9+
useNewUrlParser: true,
10+
useUnifiedTopology: true
11+
});
12+
db = await connection.db();
1013
});
1114

1215
afterAll(async () => {

mongo-insert.test.js

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,11 @@ describe('insert', () => {
55
let db;
66

77
beforeAll(async () => {
8-
connection = await MongoClient.connect(global.__MONGO_URI__, {useNewUrlParser: true});
9-
db = await connection.db(global.__MONGO_DB_NAME__);
8+
connection = await MongoClient.connect(process.env.MONGO_URL, {
9+
useNewUrlParser: true,
10+
useUnifiedTopology: true
11+
});
12+
db = await connection.db();
1013
});
1114

1215
afterAll(async () => {

readme.md

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,8 @@ module.exports = {
4343

4444
### 3. Configure MongoDB client
4545

46+
Library sets the `process.env.MONGO_URL` for your convenience
47+
4648
```js
4749
const {MongoClient} = require('mongodb');
4850

@@ -51,8 +53,11 @@ describe('insert', () => {
5153
let db;
5254

5355
beforeAll(async () => {
54-
connection = await MongoClient.connect(global.__MONGO_URI__, {useNewUrlParser: true});
55-
db = await connection.db(global.__MONGO_DB_NAME__);
56+
connection = await MongoClient.connect(process.env.MONGO_URL, {
57+
useNewUrlParser: true,
58+
useUnifiedTopology: true
59+
});
60+
db = await connection.db();
5661
});
5762

5863
afterAll(async () => {

0 commit comments

Comments
 (0)