outers
Version:
outers - a all in one package for your day to day use
33 lines • 1.67 kB
JavaScript
;
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
return new (P || (P = Promise))(function (resolve, reject) {
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments || [])).next());
});
};
Object.defineProperty(exports, "__esModule", { value: true });
const mongoose_1 = require("mongoose"); // import the mongoose module
/**
* This is an asynchronous function that connects to a MongoDB database using a provided URL.
* @param MongoURL - The MongoDB connection string that specifies the location of the MongoDB server
* and the name of the database to connect to. It typically looks like this:
* mongodb://<username>:<password>@<host>:<port>/<database>.
*/
function connectDB(MongoURL) {
return __awaiter(this, void 0, void 0, function* () {
try {
yield (0, mongoose_1.connect)(MongoURL, {
useNewUrlParser: true,
useUnifiedTopology: true
}); // connect to the database
}
catch (err) {
console.log(err);
} // catch any errors
});
} // create a function to connect to the database
exports.default = connectDB;
//# sourceMappingURL=ConnectMongo.js.map