Simplify DB configuration

pull/20/head
Joe Biellik 5 years ago
parent 96499fd793
commit ed142282e5

22
db.js

@ -1,18 +1,12 @@
const config = require('config');
const util = require('util');
const mongoose = require('mongoose');
const config = require('config');
module.exports = () => {
mongoose.Promise = global.Promise;
mongoose.connection.once('open', util.log.bind(util, 'MongoDB connection open'));
mongoose.connection.on('error', console.error.bind(console, 'MongoDB connection error:'));
mongoose.set('useCreateIndex', true);
mongoose.connection.on('error', console.error.bind(console, 'MongoDB connection error:'));
mongoose.connect(config.db, {
useNewUrlParser: true
});
mongoose.connect(config.db, {
useCreateIndex: true,
useNewUrlParser: true,
useUnifiedTopology: true
});
return mongoose.connection;
};
module.exports = mongoose.connection;

Loading…
Cancel
Save