const { MongoClient } = require("mongodb")
const { mongodb_url, database_name } = require('../config.json')

const client = new MongoClient(mongodb_url)

let database

// throw exception
module.exports.get_db = async () => {
    try {
        await client.connect()
        database = client.db(database_name)
    } catch (e) {
        throw e
    }
    return database
}