'use strict' import 'dotenv/config' import db from 'mongoose' const options = { useNewUrlParser: true, useCreateIndex: true, autoIndex: true, //this is the code I added that solved it all keepAlive: true, poolSize: 10, bufferMaxEntries: 0, connectTimeoutMS: 10000, socketTimeoutMS: 45000, family: 4, // Use IPv4, skip trying IPv6 useFindAndModify: false, useUnifiedTopology: true } db.connect(process.env.DB_URI, options) .then(() => console.log('> Successfully connected to DB')) .catch(err => console.log(err)) // syntactic sugar for { db: db } export default { db }
Preview:
downloadDownload PNG
downloadDownload JPEG
downloadDownload SVG
Tip: You can change the style, width & colours of the snippet with the inspect tool before clicking Download!
Click to optimize width for Twitter