- Create Newsletter Page: MailingList (without the class style, using Gulp tasks)#94
This commit is contained in:
47
src/server/db/mongoose.js
Normal file
47
src/server/db/mongoose.js
Normal file
@@ -0,0 +1,47 @@
|
||||
var mongoose = require('mongoose');
|
||||
|
||||
mongoose.Promise = global.Promise;
|
||||
|
||||
mongoose.level = "";
|
||||
|
||||
|
||||
mongoose.plugin(schema => {
|
||||
schema.options.usePushEach = true
|
||||
});
|
||||
|
||||
mongoose.set('debug', false);
|
||||
|
||||
var options = {
|
||||
// user: process.env.UDB,
|
||||
// pass: process.env.PDB,
|
||||
useMongoClient: true,
|
||||
// useNewUrlParser: true, // non supportato
|
||||
promiseLibrary: require('bluebird')
|
||||
|
||||
// useCreateIndex: true,
|
||||
// useFindAndModify: false,
|
||||
// autoIndex: false, // Don't build indexes
|
||||
// reconnectTries: Number.MAX_VALUE, // Never stop trying to reconnect
|
||||
// reconnectInterval: 500, // Reconnect every 500ms
|
||||
// poolSize: 10, // Maintain up to 10 socket connections
|
||||
// // If not connected, return errors immediately rather than waiting for reconnect
|
||||
// bufferMaxEntries: 0,
|
||||
// connectTimeoutMS: 10000, // Give up initial connection after 10 seconds
|
||||
// socketTimeoutMS: 45000, // Close sockets after 45 seconds of inactivity
|
||||
// family: 4 // Use IPv4, skip trying IPv6
|
||||
|
||||
// keepAlive: true, // keepAlive is true by default since mongoose 5.2.0
|
||||
// keepAliveInitialDelay: 300000 // keepAliveInitialDelay is the number of milliseconds to wait before initiating keepAlive on the socket.
|
||||
};
|
||||
|
||||
|
||||
|
||||
// mongoose.connect(process.env.MONGODB_URI + '?authSource=admin', { options })
|
||||
mongoose.connect(process.env.MONGODB_URI, options)
|
||||
.then(() =>
|
||||
console.log('connection succesful ' + process.env.MONGODB_URI + ' db: ' + process.env.DATABASE)
|
||||
|
||||
)
|
||||
.catch((err) => console.error(err));
|
||||
|
||||
module.exports = {mongoose};
|
||||
Reference in New Issue
Block a user