liquido.mongoDB.js
/** 
 * Connect to the mongo database.
 * DO NOT FORGET to call this. Mongoose will NOT complain if you forget it!!!
 */
Connect to the mongo database.
DO NOT FORGET to call this. Mongoose will NOT complain if you forget it
Connect to the mongo database . DO NOT FORGET to call this . Mongoose will NOT complain if you forget it
async function connectToDB() {
	LOG.info("Connecting to MongoDB as " + config.DB_USER + " at " + config.DB_HOST)
	try {
		await mongoose.connect(config.DB_URI, { dbName: config.DB_NAME, useNewUrlParser: true, useUnifiedTopology: true, useCreateIndex: true })
	} catch (err) {
		LOG.error("Cannot connect to DB", err)
		throw err
	}
	const db = mongoose.connection;
	db.on('error', err => LOG.error("Mongoose connection error", err));
	await db.once('open', function () {
		LOG.debug(" ... [OK]\n")
	});
}
async function connectToDB ( ) { LOG . info ( "Connecting to MongoDB as " + config . DB_USER + " at " + config . DB_HOST ) try { await mongoose . connect ( config . DB_URI , { dbName : config . DB_NAME , useNewUrlParser : true , useUnifiedTopology : true , useCreateIndex : true } ) } catch ( err ) { LOG . error ( "Cannot connect to DB" , err ) throw err } const db = mongoose . connection ; db . on ( 'error' , err => LOG . error ( "Mongoose connection error" , err ) ) ; await db . once ( 'open' , function ( ) { LOG . debug ( " ... [OK]\n" ) } ) ; }
Connect to the mongo database.
Connect to the mongo database .
// Need to use { dbName: ... }  https://stackoverflow.com/questions/48917591/fail-to-connect-mongoose-to-atlas