feat: support mongo connection with user and password (#806)

This commit is contained in:
ttimochan
2022-10-15 20:55:26 +08:00
committed by GitHub
parent 99784141eb
commit 5a20c55dc0

View File

@@ -33,8 +33,12 @@ export const MONGO_DB = {
dbName: argv.collection_name || (DEMO_MODE ? 'mx-space_demo' : 'mx-space'),
host: argv.db_host || '127.0.0.1',
port: argv.db_port || 27017,
user: argv.db_user || '',
password: argv.db_password || '',
get uri() {
return `mongodb://${this.host}:${this.port}/${
let userPassword =
this.user && this.password ? this.user + ':' + this.password + '@' : ''
return `mongodb://${userPassword}${this.host}:${this.port}/${
isTest ? 'mx-space_unitest' : this.dbName
}`
},