{"size": 520, "ext": "js", "max_stars_repo_path": "backend/db/mongoose.js", "max_stars_repo_name": "RapTho/demoApp", "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "backend/db/mongoose.js", "max_issues_repo_name": "RapTho/demoApp", "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "backend/db/mongoose.js", "max_forks_repo_name": "RapTho/demoApp", "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null}
{"max_stars_count": null, "max_issues_count": null, "max_forks_count": null, "avg_line_length": 23.6363636364, "max_line_length": 71, "alphanum_fraction": 0.6230769231}
const mongoose = require("mongoose");
const chalk = require("chalk");

const connect = async () => {
  await mongoose
    .connect(process.env.MONGODBURL, {
      useNewUrlParser: true,
      useUnifiedTopology: true,
      useCreateIndex: true,
    })
    .then(() => console.log("MongoDB connected!"))
    .catch((err) => {
      throw new Error(chalk.bold.red(`MongoDB error: ${err.message}`));
    });
};

const disconnect = async () => {
  await mongoose.disconnect();
};

module.exports = { connect, disconnect };
