Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- const mongoose = require('mongoose');
- exports.initialize = function () {
- return new Promise(function (resolve, reject) {
- console.log("initialize mongoDB...");
- const option = {
- useMongoClient: true,
- config: {
- autoIndex: true
- },
- reconnectTries: Number.MAX_VALUE,
- reconnectInterval: 1000,
- poolSize: 300,
- connectTimeoutMS: 10000, // Give up initial connection after 10 seconds
- socketTimeoutMS: 20000, // Close sockets after 45 seconds of inactivity
- };
- mongoose.connect('mongodb://localhost:27017/shop', option, function (error) {
- if (error) {
- logger.info("please make sure mongodb is running", dbConfig.mongoURL);
- reject(new Error(error));
- process.exit(1);
- return;
- }
- logger.info("connected to mongoDB", dbConfig.mongoURL);
- resolve();
- });
- });
- };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement