Skip to content

Commit 62544f4

Browse files
committed
support connections without auth
1 parent 02beee3 commit 62544f4

File tree

1 file changed

+10
-4
lines changed

1 file changed

+10
-4
lines changed

mongo-csv.js

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,13 +15,19 @@ const query = config.query || {};
1515
const projection = config.projection || {};
1616

1717
(async function() {
18+
const auth = (process.env.MONGO_USER || config.mongoUser)
19+
? {
20+
auth: {
21+
user: process.env.MONGO_USER || config.mongoUser,
22+
password: process.env.MONGO_PASSWORD || config.mongoPassword,
23+
},
24+
}
25+
: {};
26+
1827
const client = new MongoClient(url, {
19-
auth: {
20-
user: process.env.MONGO_USER || config.mongoUser,
21-
password: process.env.MONGO_PASSWORD || config.mongoPassword,
22-
},
2328
useNewUrlParser: true,
2429
authSource: authDb,
30+
...auth,
2531
});
2632

2733
try {

0 commit comments

Comments
 (0)