2020-11-08 09:28:21 -08:00
|
|
|
const mongoose = require("mongoose");
|
|
|
|
const config = require('config');
|
2021-02-27 09:25:16 -08:00
|
|
|
|
2020-11-08 09:28:21 -08:00
|
|
|
const connectToDb = async () => {
|
|
|
|
try{
|
|
|
|
await mongoose.connect(
|
|
|
|
config.get('mongoURI'),
|
|
|
|
{
|
|
|
|
useCreateIndex:true,
|
|
|
|
useFindAndModify:true,
|
|
|
|
useUnifiedTopology:true,
|
|
|
|
useNewUrlParser: true
|
|
|
|
}
|
|
|
|
)
|
|
|
|
console.log("mongo connection secure!");
|
|
|
|
|
|
|
|
} catch(error){
|
|
|
|
console.log(error);
|
|
|
|
process.exit(1);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
module.exports = connectToDb;
|