mirror of https://github.com/JoeBiellik/paste
Simplify DB configuration
parent
96499fd793
commit
ed142282e5
@ -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…
Reference in New Issue