mirror of
https://github.com/danny-avila/LibreChat.git
synced 2025-12-20 10:20:15 +01:00
🔧 fix: Make MongoDB database name configurable via environment variable
This commit is contained in:
parent
c94d4d9ae1
commit
cde930e0d6
2 changed files with 5 additions and 53 deletions
|
|
@ -1,6 +1,7 @@
|
|||
require('dotenv').config();
|
||||
const mongoose = require('mongoose');
|
||||
const MONGO_URI = process.env.MONGO_URI;
|
||||
const MONGO_DB_NAME = process.env.MONGO_DB_NAME;
|
||||
|
||||
if (!MONGO_URI) {
|
||||
throw new Error('Please define the MONGO_URI environment variable');
|
||||
|
|
@ -33,6 +34,10 @@ async function connectDb() {
|
|||
// useCreateIndex: true
|
||||
};
|
||||
|
||||
if (MONGO_DB_NAME) {
|
||||
opts.dbName = MONGO_DB_NAME;
|
||||
}
|
||||
|
||||
mongoose.set('strictQuery', true);
|
||||
cached.promise = mongoose.connect(MONGO_URI, opts).then((mongoose) => {
|
||||
return mongoose;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue