REST API upgrade
This commit is contained in:
@@ -0,0 +1,17 @@
|
||||
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
|
||||
}
|
||||
Reference in New Issue
Block a user