Skip to content

Commit c8dd223

Browse files
authored
Update init-mongo.js
1 parent c9a7138 commit c8dd223

File tree

1 file changed

+9
-5
lines changed

1 file changed

+9
-5
lines changed

examples/init-mongo.js

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,12 @@
1-
// This is only for initializing the db and creating the mailauth user
1+
const PASSWORD = process.env.MONGO_PW
2+
const USER = process.env.MONGO_USER
3+
const DB = process.env.MONGO_INITDB_DATABASE
24

3-
db = db.getSiblingDB("mailauth")
5+
db = db.getSiblingDB(DB) // Switch to your target database
46
db.createUser({
5-
user: "mailauth",
6-
pwd: "SECURE_PW", // This should match the one in your env
7-
roles: [{ role: "readWrite", db: "mailauth" }],
7+
user: USER,
8+
pwd: PASSWORD,
9+
roles: [
10+
{ role: "readWrite", db: DB }, // Give read/write access to 'mailauth'
11+
],
812
})

0 commit comments

Comments
 (0)