Skip to content

Commit

Permalink
Update database connection to use different database name based on en…
Browse files Browse the repository at this point in the history
…vironment
  • Loading branch information
chimpdev committed Mar 24, 2024
1 parent 18b0848 commit ac67134
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion server/src/database/connect.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,7 @@ const mongoose = require('mongoose');

module.exports = function connectDatabase(url) {
if (!url) throw new Error('Missing database URL.');
mongoose.connect(url, { dbName: 'api' }).then(() => logger.send('Connected to database.'));

mongoose.connect(url, { dbName: process.env.NODE_ENV === 'production' ? 'api' : 'development' })
.then(() => logger.send('Connected to database.'));
};

0 comments on commit ac67134

Please sign in to comment.