Skip to content

Instantly share code, notes, and snippets.

@nparsons08 nparsons08/db.js Secret
Created Nov 3, 2019

Embed
What would you like to do?
import mongoose from 'mongoose';
import dotenv from 'dotenv';
dotenv.config();
mongoose.Promise = global.Promise;
const connection = mongoose.connect(process.env.MONGODB_URI, {
autoIndex: true,
reconnectTries: Number.MAX_VALUE,
reconnectInterval: 500,
poolSize: 50,
bufferMaxEntries: 0,
keepAlive: 120,
useNewUrlParser: true,
});
mongoose.set('useCreateIndex', true);
connection
.then(db => db)
.catch(err => {
console.log(err);
});
export default connection;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.