Answers for "mongoose database pooling"

1

mongoose database pooling

import mongoose from 'mongoose'

	mongoose.connect(process.env.MONGO_URI, {
		minPoolSize: 1,
		maxPoolSize: 20,
		compression: { compressors: ['zlib'] },
		useUnifiedTopology: true,
		useNewUrlParser: true,
		useFindAndModify: false,
		socketTimeoutMS: 60000,
		serverSelectionTimeoutMS: 60000,
		loggerLevel: 'error'
	})

	mongoose.connection.on('connecting', () => consola.info('database connecting'))
	mongoose.connection.on('connected', () => consola.success('database connected'))
	mongoose.connection.on('disconnecting', () => consola.info('database disconnecting'))
	mongoose.connection.on('disconnected', () => consola.info('database disconnected'))
	mongoose.connection.on('error', () => consola.error('database error'))
Posted by: Guest on February-20-2021

Code answers related to "Javascript"

Browse Popular Code Answers by Language