rajamaniraja
8/24/2019 - 7:16 AM

dbutil.js

const mongoose = require("mongoose");

const clientOption = {
  socketTimeoutMS: 30000,
  keepAlive: true,
  reconnectTries: 30000,
  poolSize: 50,
  useNewUrlParser: true,
  autoIndex: false
};
const option = { useNewUrlParser: true };

const initClientDbConnection = () => {
  const db = mongoose.createConnection(config.MONGO_ATLAS, clientOption);

  db.on("error", console.error.bind(console, "MongoDB Connection Error>> : "));
  db.once("open", function() {
    console.log("client MongoDB Connection ok!");
  });
  require("user.js")
  return db;
};

module.exports = {
  initDbConnection
};