Create the API and management

This commit is contained in:
buzzcode2007 2025-03-23 07:48:47 +00:00
parent 02709cccf4
commit 31e074a5a8
3 changed files with 213 additions and 0 deletions

View file

@ -0,0 +1,21 @@
const Mongoose = require(`mongoose`);
const CustomErrors = require(`../utilities/errors`).CustomErrors;
class DBManagement {
/*
Begin the connection.
@param {string} DOMAIN the domain
@param {string} DBNAME the database name
*/
constructor (DOMAIN, DBNAME) {
const throwError = (ERROR) => {throw ERROR;};
this[`state`] = Mongoose.connect(`mongodb://${DOMAIN}/${(DBNAME) ? DBNAME : ""}`, { useNewUrlParser: true, useUnifiedTopology: true }).then((CONNECTION) => {
this[`connection`] = CONNECTION.connection;
console.log(`Connection successful.`);
}).catch(throwError);
};
}
module.exports = {DBManagement};