UNPKG

mongosuper

Version:

mongosuper is a superset of mongoose. It is a wrapper around mongoose. It manage your mongoose connection and keep it alive always. It also provide you some extra features like CRUD operations, etc.

43 lines 2.12 kB
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()); }); }; (function (factory) { if (typeof module === "object" && typeof module.exports === "object") { var v = factory(require, exports); if (v !== undefined) module.exports = v; } else if (typeof define === "function" && define.amd) { define(["require", "exports", "mongoose"], factory); } })(function (require, exports) { "use strict"; 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