mongodb database pooling

Solutions on MaxInterview for mongodb database pooling by the best coders in the world

showing results for - "mongodb database pooling"
Jazmín
27 Oct 2019
1import mongoose from 'mongoose'
2
3	mongoose.connect(process.env.MONGO_URI, {
4		minPoolSize: 1,
5		maxPoolSize: 20,
6		compression: { compressors: ['zlib'] },
7		useUnifiedTopology: true,
8		useNewUrlParser: true,
9		useFindAndModify: false,
10		socketTimeoutMS: 60000,
11		serverSelectionTimeoutMS: 60000,
12		loggerLevel: 'error'
13	})
14
15	mongoose.connection.on('connecting', () => consola.info('database connecting'))
16	mongoose.connection.on('connected', () => consola.success('database connected'))
17	mongoose.connection.on('disconnecting', () => consola.info('database disconnecting'))
18	mongoose.connection.on('disconnected', () => consola.info('database disconnected'))
19	mongoose.connection.on('error', () => consola.error('database error'))
20